6 * Copyright (C) 2017 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
30 #include "connection.h"
32 #include "sipe-core.h"
34 #include "purple-dbus.h"
35 #include "purple-private.h"
37 #if PURPLE_VERSION_CHECK(3,0,0)
39 #define purple_account_is_disconnecting(a) a->disconnecting
43 * A call to our D-Bus interface is independent from the actual libpurple
44 * state. Therefore we can't trust any of the incoming data.
46 * @param account (in) libpurple account (may be @c NULL)
48 * @return @c TRUE if it is safe to use PURPLE_ACCOUNT_TO_SIPE_CORE_PUBLIC
50 static gboolean
account_is_valid(PurpleAccount
*account
)
52 gboolean valid
= FALSE
;
55 !purple_account_is_disconnecting(account
) &&
56 (sipe_strequal(purple_account_get_protocol_id(account
), SIPE_PURPLE_PLUGIN_ID
))) {
57 PurpleConnection
*gc
= purple_account_get_connection(account
);
59 if (gc
&& PURPLE_CONNECTION_IS_CONNECTED(gc
))
67 void sipe_call_phone_number(PurpleAccount
*account
,
68 const gchar
*phone_number
)
70 /* Make sure phone number is valid before calling to core */
71 if (account_is_valid(account
) && phone_number
)
72 sipe_core_media_phone_call(PURPLE_ACCOUNT_TO_SIPE_CORE_PUBLIC
,
77 void sipe_join_conference_with_organizer_and_id(PurpleAccount
*account
,
78 const gchar
*organizer
,
79 const gchar
*meeting_id
)
81 /* Make sure organizer & ID are valid before calling to core */
82 if (account_is_valid(account
) && organizer
&& meeting_id
)
83 sipe_core_conf_create(PURPLE_ACCOUNT_TO_SIPE_CORE_PUBLIC
,
89 void sipe_join_conference_with_uri(PurpleAccount
*account
,
92 /* Make sure URI is valid before calling to core */
93 if (account_is_valid(account
) && uri
)
94 sipe_core_conf_create(PURPLE_ACCOUNT_TO_SIPE_CORE_PUBLIC
,
100 void sipe_republish_calendar(PurpleAccount
*account
)
102 if (account_is_valid(account
))
103 sipe_purple_republish_calendar(account
);
106 void sipe_reset_status(PurpleAccount
*account
)
108 if (account_is_valid(account
))
109 sipe_purple_reset_status(account
);