2 * @file miranda-buddy.c
6 * Copyright (C) 2010-12 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
28 #include "miranda-version.h"
29 #include "newpluginapi.h"
30 #include "m_protosvc.h"
31 #include "m_protoint.h"
32 #include "m_protomod.h"
33 #include "m_database.h"
36 #include "sipe-common.h"
37 #include "sipe-backend.h"
38 #include "sipe-core.h"
39 #include "miranda-private.h"
41 #define ADD_PROP(key,value) g_hash_table_insert(info_to_property_table, (gpointer)key, value)
43 static GHashTable
*info_to_property_table
= NULL
;
46 init_property_hash(void)
48 info_to_property_table
= g_hash_table_new(NULL
, NULL
);
50 // ADD_PROP(SIPE_BUDDY_INFO_DISPLAY_NAME, ALIAS_PROP);
51 ADD_PROP(SIPE_BUDDY_INFO_EMAIL
, "e-mail");
52 ADD_PROP(SIPE_BUDDY_INFO_WORK_PHONE
, "CompanyPhone");
53 // ADD_PROP(SIPE_BUDDY_INFO_WORK_PHONE_DISPLAY, PHONE_DISPLAY_PROP);
54 // ADD_PROP(SIPE_BUDDY_INFO_SITE , SITE_PROP);
55 ADD_PROP(SIPE_BUDDY_INFO_COMPANY
, "Company");
56 ADD_PROP(SIPE_BUDDY_INFO_DEPARTMENT
, "CompanyDepartment");
57 ADD_PROP(SIPE_BUDDY_INFO_JOB_TITLE
, "CompanyPosition");
58 // ADD_PROP(SIPE_BUDDY_INFO_OFFICE , OFFICE_PROP);
59 ADD_PROP(SIPE_BUDDY_INFO_STREET
, "CompanyStreet");
60 ADD_PROP(SIPE_BUDDY_INFO_CITY
, "CompanyCity");
61 ADD_PROP(SIPE_BUDDY_INFO_STATE
, "CompanyState");
62 ADD_PROP(SIPE_BUDDY_INFO_ZIPCODE
, "CompanyZIP");
63 ADD_PROP(SIPE_BUDDY_INFO_COUNTRY
, "CompanyCountry");
66 SetValue(hwndDlg,IDC_NICK,hContact,szProto,"Nick",0);
67 SetValue(hwndDlg,IDC_FIRSTNAME,hContact,szProto,"FirstName",0);
68 SetValue(hwndDlg,IDC_LASTNAME,hContact,szProto,"LastName",0);
69 SetValue(hwndDlg,IDC_EMAIL,hContact,szProto,"e-mail",0);
70 SetValue(hwndDlg,IDC_AGE,hContact,szProto,"Age",SVS_ZEROISUNSPEC);
71 SetValue(hwndDlg,IDC_GENDER,hContact,szProto,"Gender",SVS_GENDER);
72 SetValue(hwndDlg,IDC_DOBDAY,hContact,szProto,"BirthDay",0);
73 SetValue(hwndDlg,IDC_DOBMONTH,hContact,szProto,"BirthMonth",SVS_MONTH);
74 SetValue(hwndDlg,IDC_DOBYEAR,hContact,szProto,"BirthYear",0);
77 SetValue(hwndDlg,IDC_STREET,hContact,szProto,"Street",SVS_ZEROISUNSPEC);
78 SetValue(hwndDlg,IDC_CITY,hContact,szProto,"City",SVS_ZEROISUNSPEC);
79 SetValue(hwndDlg,IDC_STATE,hContact,szProto,"State",SVS_ZEROISUNSPEC);
80 SetValue(hwndDlg,IDC_ZIP,hContact,szProto,"ZIP",SVS_ZEROISUNSPEC);
81 SetValue(hwndDlg,IDC_COUNTRY,hContact,szProto,"Country",SVS_COUNTRY);
82 SetValue(hwndDlg,IDC_LANGUAGE1,hContact,szProto,"Language1",SVS_ZEROISUNSPEC);
83 SetValue(hwndDlg,IDC_LANGUAGE2,hContact,szProto,"Language2",SVS_ZEROISUNSPEC);
84 SetValue(hwndDlg,IDC_LANGUAGE3,hContact,szProto,"Language3",SVS_ZEROISUNSPEC);
85 SetValue(hwndDlg,IDC_TIMEZONE,hContact,szProto,"Timezone",SVS_TIMEZONE);
88 SetValue(hwndDlg,IDC_COMPANY,hContact,szProto,"Company",SVS_ZEROISUNSPEC);
89 SetValue(hwndDlg,IDC_DEPARTMENT,hContact,szProto,"CompanyDepartment",SVS_ZEROISUNSPEC);
90 SetValue(hwndDlg,IDC_POSITION,hContact,szProto,"CompanyPosition",SVS_ZEROISUNSPEC);
91 SetValue(hwndDlg,IDC_STREET,hContact,szProto,"CompanyStreet",SVS_ZEROISUNSPEC);
92 SetValue(hwndDlg,IDC_CITY,hContact,szProto,"CompanyCity",SVS_ZEROISUNSPEC);
93 SetValue(hwndDlg,IDC_STATE,hContact,szProto,"CompanyState",SVS_ZEROISUNSPEC);
94 SetValue(hwndDlg,IDC_ZIP,hContact,szProto,"CompanyZIP",SVS_ZEROISUNSPEC);
95 SetValue(hwndDlg,IDC_COUNTRY,hContact,szProto,"CompanyCountry",SVS_COUNTRY);
96 SetValue(hwndDlg,IDC_WEBPAGE,hContact,szProto,"CompanyHomepage",SVS_ZEROISUNSPEC);
99 SetValue(hwndDlg,IDC_WEBPAGE,hContact,szProto,"Homepage",SVS_ZEROISUNSPEC);
102 if(DBGetContactSettingTString(hContact,szProto,"e-mail",&dbv))
103 mir_snprintf(idstr, SIZEOF(idstr), "e-mail%d", i );
104 mir_snprintf(idstr, SIZEOF(idstr), "Mye-mail%d",i);
105 if(!DBGetContactSettingTString(hContact,szProto,"Phone",&dbv)) {
106 if(!DBGetContactSettingTString(hContact,szProto,"Fax",&dbv)) {
107 if(!DBGetContactSettingTString(hContact,szProto,"Cellular",&dbv)) {
108 if(!DBGetContactSettingTString(hContact,szProto,"CompanyPhone",&dbv)) {
109 if(!DBGetContactSettingTString(hContact,szProto,"CompanyFax",&dbv)) {
110 mir_snprintf(idstr, SIZEOF(idstr), "MyPhone%d",i);
116 sipe_info_to_miranda_property(sipe_buddy_info_fields info
)
118 if (!info_to_property_table
)
119 init_property_hash();
120 return (const char *)g_hash_table_lookup(info_to_property_table
, (gconstpointer
)info
);
123 sipe_backend_buddy
sipe_miranda_buddy_find(SIPPROTO
*pr
,
129 hContact
= (HANDLE
)CallService(MS_DB_CONTACT_FINDFIRST
, 0, 0);
131 gchar
* szProto
= (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO
, (WPARAM
)hContact
, 0);
132 if (szProto
!= NULL
&& !lstrcmpA(szProto
, pr
->proto
.m_szModuleName
)) {
134 if ( !DBGetContactSettingString( hContact
, pr
->proto
.m_szModuleName
, SIP_UNIQUEID
, &dbv
)) {
135 int tCompareResult
= lstrcmpiA( dbv
.pszVal
, name
);
136 DBFreeVariant( &dbv
);
137 if ( !tCompareResult
) {
140 SIPE_DEBUG_INFO("buddy_name <%s> group <%s> found <%08x>", name
, group
, hContact
);
144 if ( !DBGetContactSettingStringUtf(hContact
, "CList", "Group", &dbv
)) {
145 int tCompareResult
= lstrcmpiA( dbv
.pszVal
, group
);
146 DBFreeVariant( &dbv
);
147 if ( !tCompareResult
)
149 SIPE_DEBUG_INFO("buddy_name <%s> group <%s> found <%08x> in group", name
, group
, hContact
);
153 SIPE_DEBUG_INFO("buddy_name <%s> group <%s> ERROR getting contact group", name
, group
);
159 hContact
= (HANDLE
)CallService(MS_DB_CONTACT_FINDNEXT
, (WPARAM
)hContact
, 0);
162 SIPE_DEBUG_INFO("buddy_name <%s> group <%s> NOT FOUND", name
, group
);
165 sipe_backend_buddy
sipe_backend_buddy_find(struct sipe_core_public
*sipe_public
,
169 return sipe_miranda_buddy_find(sipe_public
->backend_private
, name
, group
);
172 GSList
* sipe_miranda_buddy_find_all(SIPPROTO
*pr
,
173 const gchar
*buddy_name
,
174 const gchar
*group_name
)
179 hContact
= (HANDLE
)CallService(MS_DB_CONTACT_FINDFIRST
, 0, 0);
181 gchar
* szProto
= (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO
, (WPARAM
)hContact
, 0);
182 if (szProto
!= NULL
&& !lstrcmpA(szProto
, pr
->proto
.m_szModuleName
)) {
183 if (DBGetContactSettingByte(hContact
, pr
->proto
.m_szModuleName
, "ChatRoom", 0) == 0) {
186 res
= g_slist_append(res
, hContact
);
187 else if ( !DBGetContactSettingString( hContact
, pr
->proto
.m_szModuleName
, SIP_UNIQUEID
, &dbv
)) {
188 int tCompareResult
= lstrcmpiA( dbv
.pszVal
, buddy_name
);
189 DBFreeVariant( &dbv
);
190 if ( !tCompareResult
) {
192 res
= g_slist_append(res
, hContact
);
194 else if ( !DBGetContactSettingStringUtf(hContact
, "CList", "Group", &dbv
)) {
195 int tCompareResult
= lstrcmpiA( dbv
.pszVal
, group_name
);
196 DBFreeVariant( &dbv
);
197 if ( !tCompareResult
)
198 res
= g_slist_append(res
, hContact
);
202 SIPE_DEBUG_INFO_NOFORMAT("Could not get SIP id from contact");
206 hContact
= (HANDLE
)CallService(MS_DB_CONTACT_FINDNEXT
, (WPARAM
)hContact
, 0);
209 SIPE_DEBUG_INFO("name <%s> group <%s> found <%d> buddies", buddy_name
, group_name
, g_slist_length(res
));
213 GSList
* sipe_backend_buddy_find_all(struct sipe_core_public
*sipe_public
,
214 const gchar
*buddy_name
,
215 const gchar
*group_name
)
217 return sipe_miranda_buddy_find_all(sipe_public
->backend_private
, buddy_name
, group_name
);
220 gchar
* sipe_backend_buddy_get_name(struct sipe_core_public
*sipe_public
,
221 const sipe_backend_buddy who
)
224 HANDLE hContact
= (HANDLE
)who
;
226 SIPPROTO
*pr
= sipe_public
->backend_private
;
227 const gchar
*module
= pr
->proto
.m_szModuleName
;
229 if ( !DBGetContactSettingString( hContact
, module
, SIP_UNIQUEID
, &dbv
)) {
230 alias
= g_strdup(dbv
.pszVal
);
231 DBFreeVariant( &dbv
);
238 gchar
* sipe_backend_buddy_get_alias(struct sipe_core_public
*sipe_public
,
239 const sipe_backend_buddy who
)
242 HANDLE hContact
= (HANDLE
)who
;
244 SIPPROTO
*pr
= sipe_public
->backend_private
;
245 const gchar
*module
= pr
->proto
.m_szModuleName
;
247 if ( DBGetContactSettingString( hContact
, module
, "Nick", &dbv
)
248 && DBGetContactSettingString( hContact
, module
, "Alias", &dbv
)
249 && DBGetContactSettingString( hContact
, module
, SIP_UNIQUEID
, &dbv
))
252 alias
= g_strdup(dbv
.pszVal
);
253 DBFreeVariant( &dbv
);
257 gchar
* sipe_backend_buddy_get_server_alias(struct sipe_core_public
*sipe_public
,
258 const sipe_backend_buddy who
)
261 HANDLE hContact
= (HANDLE
)who
;
263 SIPPROTO
*pr
= sipe_public
->backend_private
;
264 const gchar
*module
= pr
->proto
.m_szModuleName
;
266 if ( !DBGetContactSettingString( hContact
, module
, "Alias", &dbv
)) {
267 alias
= g_strdup(dbv
.pszVal
);
268 DBFreeVariant( &dbv
);
275 gchar
* sipe_backend_buddy_get_local_alias(struct sipe_core_public
*sipe_public
,
276 const sipe_backend_buddy who
)
279 HANDLE hContact
= (HANDLE
)who
;
281 SIPPROTO
*pr
= sipe_public
->backend_private
;
282 const gchar
*module
= pr
->proto
.m_szModuleName
;
284 if ( DBGetContactSettingString( hContact
, module
, "Nick", &dbv
)
285 && DBGetContactSettingString( hContact
, module
, SIP_UNIQUEID
, &dbv
))
288 alias
= g_strdup(dbv
.pszVal
);
289 DBFreeVariant( &dbv
);
293 gchar
* sipe_backend_buddy_get_group_name(struct sipe_core_public
*sipe_public
,
294 const sipe_backend_buddy who
)
297 HANDLE hContact
= (HANDLE
)who
;
299 SIPPROTO
*pr
= sipe_public
->backend_private
;
300 const gchar
*module
= pr
->proto
.m_szModuleName
;
302 if ( !DBGetContactSettingString( hContact
, "CList", "Group", &dbv
)) {
303 alias
= g_strdup(dbv
.pszVal
);
304 DBFreeVariant( &dbv
);
311 guint
sipe_backend_buddy_get_status(struct sipe_core_public
*sipe_public
,
314 SIPPROTO
*pr
= sipe_public
->backend_private
;
315 sipe_backend_buddy buddy
= sipe_backend_buddy_find(sipe_public
, uri
, NULL
);
316 WORD rv
= SIPE_ACTIVITY_UNSET
;
318 sipe_miranda_getWord(pr
, buddy
, "Status", &rv
);
319 return MirandaStatusToSipe(rv
);
322 void sipe_backend_buddy_set_alias(struct sipe_core_public
*sipe_public
,
323 const sipe_backend_buddy who
,
326 SIPPROTO
*pr
= sipe_public
->backend_private
;
327 HANDLE hContact
= (HANDLE
)who
;
329 SIPE_DEBUG_INFO("Set alias of contact <%08x> to <%s>", who
, alias
);
330 sipe_miranda_setContactStringUtf( pr
, hContact
, "Nick", alias
);
333 void sipe_backend_buddy_set_server_alias(struct sipe_core_public
*sipe_public
,
334 const sipe_backend_buddy who
,
337 HANDLE hContact
= (HANDLE
)who
;
338 SIPPROTO
*pr
= sipe_public
->backend_private
;
340 SIPE_DEBUG_INFO("Set alias of contact <%08x> to <%s>", who
, alias
);
341 sipe_miranda_setContactStringUtf( pr
, hContact
, "Alias", alias
);
344 gchar
* sipe_backend_buddy_get_string(struct sipe_core_public
*sipe_public
,
345 sipe_backend_buddy buddy
,
346 const sipe_buddy_info_fields key
)
348 SIPPROTO
*pr
= sipe_public
->backend_private
;
349 const gchar
*module
= pr
->proto
.m_szModuleName
;
350 const gchar
*prop_name
= sipe_info_to_miranda_property(key
);
357 tmp
= sipe_miranda_getContactString(pr
, buddy
, prop_name
);
358 prop_str
= g_strdup(tmp
);
364 void sipe_backend_buddy_set_string(struct sipe_core_public
*sipe_public
,
365 sipe_backend_buddy buddy
,
366 const sipe_buddy_info_fields key
,
369 SIPPROTO
*pr
= sipe_public
->backend_private
;
370 const gchar
*module
= pr
->proto
.m_szModuleName
;
371 const gchar
*prop_name
= sipe_info_to_miranda_property(key
);
373 SIPE_DEBUG_INFO("buddy <%08x> key <%d = %s> val <%s>", buddy
, key
, prop_name
, val
);
377 sipe_miranda_setContactString(pr
, buddy
, prop_name
, val
);
380 void sipe_backend_buddy_refresh_properties(SIPE_UNUSED_PARAMETER
struct sipe_core_public
*sipe_public
,
381 SIPE_UNUSED_PARAMETER
const gchar
*uri
)
383 /* nothing to do here: already taken care of by Miranda */
386 void sipe_backend_buddy_list_processing_start(SIPE_UNUSED_PARAMETER
struct sipe_core_public
*sipe_public
)
390 void sipe_backend_buddy_list_processing_finish(SIPE_UNUSED_PARAMETER
struct sipe_core_public
*sipe_public
)
394 sipe_backend_buddy
sipe_backend_buddy_add(struct sipe_core_public
*sipe_public
,
397 const gchar
*groupname
)
399 SIPPROTO
*pr
= sipe_public
->backend_private
;
402 SIPE_DEBUG_INFO("Adding miranda contact for buddy <%s> alias <%s> in <%s>", name
, alias
, groupname
);
403 hContact
= ( HANDLE
)CallService( MS_DB_CONTACT_ADD
, 0, 0 );
404 CallService( MS_PROTO_ADDTOCONTACT
, ( WPARAM
)hContact
,( LPARAM
)pr
->proto
.m_szModuleName
);
405 sipe_miranda_setContactString( pr
, hContact
, SIP_UNIQUEID
, name
); // name
406 if (alias
) sipe_miranda_setContactStringUtf( pr
, hContact
, "Nick", alias
);
407 DBWriteContactSettingString( hContact
, "CList", "Group", groupname
);
408 sipe_miranda_setContactString( pr
, hContact
, "Group", groupname
);
409 return (sipe_backend_buddy
)hContact
;
412 void sipe_backend_buddy_remove(struct sipe_core_public
*sipe_public
,
413 const sipe_backend_buddy who
)
415 CallService( MS_DB_CONTACT_DELETE
, (WPARAM
)who
, 0 );
418 void sipe_backend_buddy_request_authorization(struct sipe_core_public
*sipe_public
,
422 sipe_backend_buddy_request_authorization_cb auth_cb
,
423 sipe_backend_buddy_request_authorization_cb deny_cb
,
426 SIPPROTO
*pr
= sipe_public
->backend_private
;
428 PROTORECVEVENT pre
= {0};
432 hContact
= sipe_backend_buddy_find( sipe_public
, who
, NULL
);
435 SIPE_DEBUG_INFO("Adding miranda contact for incoming talker <%s>", who
);
436 hContact
= ( HANDLE
)CallService( MS_DB_CONTACT_ADD
, 0, 0 );
437 CallService( MS_PROTO_ADDTOCONTACT
, ( WPARAM
)hContact
,( LPARAM
)pr
->proto
.m_szModuleName
);
438 DBWriteContactSettingByte( hContact
, "CList", "NotOnList", 1 );
439 sipe_miranda_setContactString( pr
, hContact
, SIP_UNIQUEID
, who
); // name
442 ccs
.szProtoService
= PSR_AUTH
;
443 ccs
.hContact
= hContact
;
445 ccs
.lParam
= (LPARAM
) &pre
;
447 pre
.flags
= PREF_UTF
;
448 pre
.timestamp
= time(NULL
);
449 pre
.lParam
= sizeof(DWORD
)+sizeof(HANDLE
)+strlen(who
)+strlen(alias
)+5;
450 pre
.szMessage
= malloc(pre
.lParam
);
452 pblob
= pre
.szMessage
;
454 *(DWORD
*)pblob
= 0; /* UIN */
455 pblob
+= sizeof(DWORD
);
457 *(HANDLE
*)pblob
= hContact
; /* contact */
458 pblob
+= sizeof(HANDLE
);
460 strcpy(pblob
, who
); /* nick */
461 pblob
+= strlen(pblob
) + 1;
463 strcpy(pblob
, alias
); /* first name */
464 pblob
+= strlen(pblob
) + 1;
466 strcpy(pblob
, ""); /* last name */
467 pblob
+= strlen(pblob
) + 1;
469 strcpy(pblob
, ""); /* email */
470 pblob
+= strlen(pblob
) + 1;
472 strcpy(pblob
, ""); /* msg */
473 pblob
+= strlen(pblob
) + 1;
475 CallService(MS_PROTO_CHAINRECV
, 0, (LPARAM
)&ccs
);
481 void sipe_backend_buddy_request_add(struct sipe_core_public
*sipe_public
,
488 gboolean
sipe_backend_buddy_is_blocked(struct sipe_core_public
*sipe_public
,
495 void sipe_backend_buddy_set_blocked_status(struct sipe_core_public
*sipe_public
,
502 void sipe_backend_buddy_set_status(struct sipe_core_public
*sipe_public
,
506 SIPPROTO
*pr
= sipe_public
->backend_private
;
507 GSList
*contacts
= sipe_backend_buddy_find_all(sipe_public
, who
, NULL
);
509 CONTACTS_FOREACH(contacts
)
510 sipe_miranda_setWord(pr
, hContact
, "Status", SipeStatusToMiranda(activity
));
511 CONTACTS_FOREACH_END
;
515 gboolean
sipe_backend_buddy_group_add(struct sipe_core_public
*sipe_public
,
516 const gchar
*group_name
)
518 TCHAR
*mir_group_name
= mir_a2t(group_name
);
519 HANDLE hGroup
= (HANDLE
)CallService(MS_CLIST_GROUPCREATE
, 0, (LPARAM
)mir_group_name
);
520 mir_free(mir_group_name
);
521 return (hGroup
?TRUE
:FALSE
);
524 gboolean
sipe_backend_buddy_group_rename(SIPE_UNUSED_PARAMETER
struct sipe_core_public
*sipe_public
,
525 SIPE_UNUSED_PARAMETER
const gchar
*old_name
,
526 SIPE_UNUSED_PARAMETER
const gchar
*new_name
)
532 void sipe_backend_buddy_group_remove(SIPE_UNUSED_PARAMETER
struct sipe_core_public
*sipe_public
,
533 SIPE_UNUSED_PARAMETER
const gchar
*group_name
)
538 struct sipe_backend_buddy_info
*sipe_backend_buddy_info_start(SIPE_UNUSED_PARAMETER
struct sipe_core_public
*sipe_public
)
540 return((struct sipe_backend_buddy_info
*)g_hash_table_new_full(NULL
,NULL
,NULL
,g_free
));
543 void sipe_backend_buddy_info_add(SIPE_UNUSED_PARAMETER
struct sipe_core_public
*sipe_public
,
544 struct sipe_backend_buddy_info
*info
,
545 sipe_buddy_info_fields description
,
548 g_hash_table_insert((GHashTable
*)info
, (gpointer
)description
, g_strdup(value
));
551 void sipe_backend_buddy_info_break(SIPE_UNUSED_PARAMETER
struct sipe_core_public
*sipe_public
,
552 struct sipe_backend_buddy_info
*info
)
557 static void set_if_defined(SIPPROTO
*pr
, GHashTable
*store
, HANDLE hContact
, sipe_buddy_info_fields field
, char *label
)
559 char *value
= (char *)g_hash_table_lookup(store
, (gpointer
)field
);
561 sipe_miranda_setContactStringUtf(pr
, hContact
, label
, value
);
564 void sipe_backend_buddy_info_finalize(struct sipe_core_public
*sipe_public
,
565 struct sipe_backend_buddy_info
*info
,
568 SIPPROTO
*pr
= sipe_public
->backend_private
;
569 HANDLE hContact
= sipe_miranda_buddy_find(pr
, uri
, NULL
); /* (HANDLE) data; */
571 GHashTable
*results
= (GHashTable
*)info
;
574 const char *id
, *value
;
576 g_hash_table_iter_init( &iter
, results
);
577 while (g_hash_table_iter_next (&iter
, (gpointer
*)&id
, (gpointer
*)&value
)) {
578 SIPE_DEBUG_INFO("miranda_sipe_get_info_cb: user info field <%d> = <%s>", id
, value
? value
: "(none)");
580 set_if_defined(pr
, results
, hContact
, SIPE_BUDDY_INFO_EMAIL
, "e-mail");
581 set_if_defined(pr
, results
, hContact
, SIPE_BUDDY_INFO_CITY
, "City");
582 set_if_defined(pr
, results
, hContact
, SIPE_BUDDY_INFO_STATE
, "State");
583 set_if_defined(pr
, results
, hContact
, SIPE_BUDDY_INFO_COUNTRY
, "Country");
584 set_if_defined(pr
, results
, hContact
, SIPE_BUDDY_INFO_COMPANY
, "Company");
585 set_if_defined(pr
, results
, hContact
, SIPE_BUDDY_INFO_JOB_TITLE
, "CompanyPosition");
586 set_if_defined(pr
, results
, hContact
, SIPE_BUDDY_INFO_WORK_PHONE
, "CompanyPhone");
587 set_if_defined(pr
, results
, hContact
, SIPE_BUDDY_INFO_STREET
, "CompanyStreet");
588 set_if_defined(pr
, results
, hContact
, SIPE_BUDDY_INFO_ZIPCODE
, "CompanyZIP");
589 set_if_defined(pr
, results
, hContact
, SIPE_BUDDY_INFO_DEPARTMENT
, "CompanyDepartment");
591 if ( !DBGetContactSettingString( hContact
, pr
->proto
.m_szModuleName
, SIP_UNIQUEID
, &dbv
)) {
592 GString
*content
= g_string_new(NULL
);
598 sipe_miranda_getWord(pr
, hContact
, "Status", &wstatus
);
599 status
= (gchar
*)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION
, (WPARAM
)wstatus
, (LPARAM
)GSMDF_PREFIXONLINE
);
600 is_online
= g_str_has_prefix(status
, "Online: ") || !g_ascii_strcasecmp(status
, "Online");
602 info = sipe_core_buddy_info(sipe_public,
604 g_str_has_prefix(status, "Online: ") ? status+8 : status,
608 struct sipe_buddy_info *sbi = info->data;
609 g_string_append_printf(content, "%s: %s\r\n", sbi->label, sbi->text);
612 info = g_slist_delete_link(info, info);
614 sipe_miranda_setContactStringUtf(pr, hContact, "About", content->str);
616 g_string_free(content
, TRUE
);
619 sipe_miranda_SendBroadcast(pr
, hContact
, ACKTYPE_GETINFO
, ACKRESULT_SUCCESS
, (HANDLE
) 1, (LPARAM
) 0);
622 struct sipe_backend_buddy_menu
*sipe_backend_buddy_menu_start(SIPE_UNUSED_PARAMETER
struct sipe_core_public
*sipe_public
)
627 struct sipe_backend_buddy_menu
*sipe_backend_buddy_menu_add(SIPE_UNUSED_PARAMETER
struct sipe_core_public
*sipe_public
,
628 struct sipe_backend_buddy_menu
*menu
,
630 enum sipe_buddy_menu_type type
,
637 struct sipe_backend_buddy_menu
*sipe_backend_buddy_menu_separator(SIPE_UNUSED_PARAMETER
struct sipe_core_public
*sipe_public
,
638 struct sipe_backend_buddy_menu
*menu
,
645 struct sipe_backend_buddy_menu
*sipe_backend_buddy_sub_menu_add(SIPE_UNUSED_PARAMETER
struct sipe_core_public
*sipe_public
,
646 struct sipe_backend_buddy_menu
*menu
,
648 struct sipe_backend_buddy_menu
*sub
)
654 void sipe_backend_buddy_tooltip_add(SIPE_UNUSED_PARAMETER
struct sipe_core_public
*sipe_public
,
655 struct sipe_backend_buddy_tooltip
*tooltip
,
656 const gchar
*description
,
662 int sipe_miranda_buddy_delete(SIPPROTO
*pr
, WPARAM wParam
, LPARAM lParam
)
665 HANDLE hContact
= (HANDLE
)wParam
;
669 SIPE_DEBUG_INFO("Deleting contact <%08x>", hContact
);
671 if ( DBGetContactSettingString( hContact
, pr
->proto
.m_szModuleName
, SIP_UNIQUEID
, &dbv
))
674 name
= g_strdup(dbv
.pszVal
);
675 DBFreeVariant( &dbv
);
677 if ( DBGetContactSettingString( hContact
, "CList", "Group", &dbv
))
683 groupname
= g_strdup(dbv
.pszVal
);
684 DBFreeVariant( &dbv
);
687 sipe_core_buddy_remove(pr
->sip
, name
, groupname
);
693 unsigned GetAwayMsgThread(SIPPROTO
*pr
, HANDLE hContact
)
696 gchar
*name
= sipe_miranda_getContactString(pr
, hContact
, SIP_UNIQUEID
);
701 SIPE_DEBUG_INFO("Could not find name for contact <%08x>", hContact
);
702 sipe_miranda_SendProtoAck(pr
, hContact
, 1, ACKRESULT_FAILED
, ACKTYPE_AWAYMSG
, NULL
);
707 status
= sipe_core_buddy_status(pr
->sip
,
709 SIPE_ACTIVITY_BUSYIDLE
,
710 "dummy test string");
714 tmp
= sipe_miranda_eliminate_html(status
, strlen(status
));
716 sipe_miranda_SendProtoAck(pr
, hContact
, 1, ACKRESULT_SUCCESS
, ACKTYPE_AWAYMSG
, tmp
);
724 sipe_miranda_GetAwayMsg( SIPPROTO
*pr
, HANDLE hContact
)
726 CloseHandle((HANDLE
)mir_forkthreadowner(&GetAwayMsgThread
, pr
, hContact
, NULL
));
731 sipe_miranda_GetInfo( SIPPROTO
*pr
, HANDLE hContact
, int infoType
)
735 SIPE_DEBUG_INFO("GetInfo: infotype <%x>", infoType
);
736 if (!pr
->sip
) return 0;
738 if ( !DBGetContactSettingString( hContact
, pr
->proto
.m_szModuleName
, SIP_UNIQUEID
, &dbv
)) {
740 sipe_core_buddy_get_info(pr
->sip
, dbv
.pszVal
);
742 DBFreeVariant( &dbv
);
748 gboolean
sipe_backend_uses_photo(void)
753 void sipe_backend_buddy_set_photo(struct sipe_core_public
*sipe_public
,
757 const gchar
*photo_hash
)
762 const gchar
*sipe_backend_buddy_get_photo_hash(struct sipe_core_public
*sipe_public
,
765 const gchar
*result
= NULL
;