6 * Copyright (C) 2010-2018 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
32 #include "purple-private.h"
34 #if PURPLE_VERSION_CHECK(3,0,0)
36 #define purple_serv_got_typing(c, n, t, s) serv_got_typing(c, n, t, s)
37 #define purple_serv_got_typing_stopped(c, n) serv_got_typing_stopped(c, n)
38 #define PURPLE_IM_TYPING PURPLE_TYPING
41 #include "sipe-backend.h"
42 #include "sipe-common.h"
43 #include "sipe-core.h"
46 #define SIPE_TYPING_RECV_TIMEOUT 6
48 void sipe_backend_user_feedback_typing(struct sipe_core_public
*sipe_public
,
51 struct sipe_backend_private
*purple_private
= sipe_public
->backend_private
;
52 purple_serv_got_typing(purple_private
->gc
, from
,
53 SIPE_TYPING_RECV_TIMEOUT
,
57 void sipe_backend_user_feedback_typing_stop(struct sipe_core_public
*sipe_public
,
60 struct sipe_backend_private
*purple_private
= sipe_public
->backend_private
;
61 purple_serv_got_typing_stopped(purple_private
->gc
, from
);
64 static void accept_cb(gpointer key
, SIPE_UNUSED_PARAMETER
int choice
)
66 sipe_core_user_ask_cb(key
, TRUE
);
69 static void decline_cb(gpointer key
, SIPE_UNUSED_PARAMETER
int choice
)
71 sipe_core_user_ask_cb(key
, FALSE
);
74 void sipe_backend_user_ask(struct sipe_core_public
*sipe_public
,
76 const gchar
*accept_label
,
77 const gchar
*decline_label
,
80 struct sipe_backend_private
*purple_private
= sipe_public
->backend_private
;
82 purple_request_action(key
, "Office Communicator", message
,
84 #if PURPLE_VERSION_CHECK(3,0,0)
85 purple_request_cpar_from_account(purple_private
->account
),
87 purple_private
->account
, NULL
, NULL
,
89 key
, decline_label
? 2 : 1,
90 accept_label
, (PurpleRequestActionCb
) accept_cb
,
91 decline_label
, (PurpleRequestActionCb
) decline_cb
);
94 void sipe_backend_user_close_ask(gpointer key
)
96 purple_request_close_with_handle(key
);
99 static void ask_choice_accept_cb(gpointer key
, PurpleRequestFields
*fields
)
102 GPOINTER_TO_INT(purple_request_fields_get_choice(fields
, "choice"));
104 sipe_core_user_ask_choice_cb(key
, choice_id
);
107 static void ask_choice_cancel_cb(gpointer key
)
109 sipe_core_user_ask_choice_cb(key
, SIPE_CHOICE_CANCELLED
);
113 void sipe_backend_user_ask_choice(struct sipe_core_public
*sipe_public
,
114 const gchar
*message
,
118 struct sipe_backend_private
*purple_private
= sipe_public
->backend_private
;
120 PurpleRequestFields
*fields
= purple_request_fields_new();
121 PurpleRequestFieldGroup
*group
= purple_request_field_group_new(NULL
);
122 PurpleRequestField
*field
=
123 purple_request_field_choice_new("choice", message
, 0);
126 for (i
= 0; i
!= g_slist_length(choices
); ++i
) {
127 purple_request_field_choice_add(field
,
128 g_slist_nth_data(choices
, i
)
129 #if PURPLE_VERSION_CHECK(3,0,0)
130 , GUINT_TO_POINTER(i
)
135 purple_request_field_group_add_field(group
, field
);
136 purple_request_fields_add_group(fields
, group
);
138 purple_request_fields(key
, "Microsoft Lync",
140 _("OK"), (GCallback
)ask_choice_accept_cb
,
141 _("Cancel"), (GCallback
)ask_choice_cancel_cb
,
142 #if PURPLE_VERSION_CHECK(3,0,0)
143 purple_request_cpar_from_account(purple_private
->account
),
145 purple_private
->account
, NULL
, NULL
,