2 * @file purple-status.c
6 * Copyright (C) 2011 SIPE Project <http://sipe.sourceforge.net/>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include "savedstatuses.h"
28 #include "sipe-backend.h"
29 #include "sipe-core.h"
31 #include "purple-private.h"
33 /* Status attributes */
34 #define PURPLE_STATUS_ATTR_ID_MESSAGE "message"
37 * This method motivates Purple's Host (e.g. Pidgin) to update its UI
38 * by using standard Purple's means of signals and saved statuses.
40 * Thus all UI elements get updated: Status Button with Note, docklet.
41 * This is ablolutely important as both our status and note can come
42 * inbound (roaming) or be updated programmatically (e.g. based on our
45 gboolean
sipe_backend_status_and_note(struct sipe_core_public
*sipe_public
,
46 const gchar
*status_id
,
49 struct sipe_backend_private
*purple_private
= sipe_public
->backend_private
;
50 PurpleAccount
*account
= purple_private
->account
;
51 PurpleStatus
*status
= purple_account_get_active_status(account
);
52 gboolean changed
= TRUE
;
54 if (g_str_equal(status_id
, purple_status_get_id(status
)) &&
55 sipe_strequal(message
,
56 purple_status_get_attr_string(status
,
57 PURPLE_STATUS_ATTR_ID_MESSAGE
)))
62 if (purple_savedstatus_is_idleaway()) {
67 PurpleSavedStatus
*saved_status
;
68 const PurpleStatusType
*acct_status_type
=
69 purple_status_type_find_with_id(account
->status_types
, status_id
);
70 PurpleStatusPrimitive primitive
= purple_status_type_get_primitive(acct_status_type
);
72 saved_status
= purple_savedstatus_find_transient_by_type_and_message(primitive
, message
);
74 purple_savedstatus_set_substatus(saved_status
, account
, acct_status_type
, message
);
77 /* If this type+message is unique then create a new transient saved status
82 GList
*active_accts
= purple_accounts_get_all_active();
84 saved_status
= purple_savedstatus_new(NULL
, primitive
);
85 purple_savedstatus_set_message(saved_status
, message
);
87 for (tmp
= active_accts
; tmp
!= NULL
; tmp
= tmp
->next
) {
88 purple_savedstatus_set_substatus(saved_status
,
89 (PurpleAccount
*)tmp
->data
, acct_status_type
, message
);
91 g_list_free(active_accts
);
94 /* Set the status for each account */
95 purple_savedstatus_activate(saved_status
);