OBS: update support for CentOS & Scientific Linux 7
[siplcs.git] / src / purple / purple-dbus.c
blob499d1628975f8b441e3b85774c947a140749cc72
1 /**
2 * @file purple-dbus.c
4 * pidgin-sipe
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
23 #ifdef HAVE_CONFIG_H
24 #include "config.h"
25 #endif
27 #include <glib.h>
29 #include "account.h"
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)
38 #else
39 #define purple_account_is_disconnecting(a) a->disconnecting
40 #endif
42 /**
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;
54 if (account &&
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))
60 valid = TRUE;
63 return(valid);
66 #ifdef HAVE_VV
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,
73 phone_number);
75 #endif
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,
84 NULL,
85 organizer,
86 meeting_id);
89 void sipe_join_conference_with_uri(PurpleAccount *account,
90 const gchar *uri)
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,
95 uri,
96 NULL,
97 NULL);
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);
113 Local Variables:
114 mode: c
115 c-file-style: "bsd"
116 indent-tabs-mode: t
117 tab-width: 8
118 End: