annotate src/protocols/novell/nmuser.c @ 8887:56339eb6dab1

[gaim-migrate @ 9656] A patch from GoRN (Kevin Barry) to make the text entry in the edit-an- away-message box focusable. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Thu, 06 May 2004 05:24:15 +0000
parents a2affcdf8e01
children 6663ad2386d9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /*
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 * nmuser.c
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 *
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
4 * Copyright © 2004 Unpublished Work of Novell, Inc. All Rights Reserved.
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 *
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
6 * THIS WORK IS AN UNPUBLISHED WORK OF NOVELL, INC. NO PART OF THIS WORK MAY BE
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 * USED, PRACTICED, PERFORMED, COPIED, DISTRIBUTED, REVISED, MODIFIED,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * TRANSLATED, ABRIDGED, CONDENSED, EXPANDED, COLLECTED, COMPILED, LINKED,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 * RECAST, TRANSFORMED OR ADAPTED WITHOUT THE PRIOR WRITTEN CONSENT OF NOVELL,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 * INC. ANY USE OR EXPLOITATION OF THIS WORK WITHOUT AUTHORIZATION COULD SUBJECT
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * THE PERPETRATOR TO CRIMINAL AND CIVIL LIABILITY.
8684
046dd8ef2920 [gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents: 8675
diff changeset
12 *
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * AS BETWEEN [GAIM] AND NOVELL, NOVELL GRANTS [GAIM] THE RIGHT TO REPUBLISH
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * THIS WORK UNDER THE GPL (GNU GENERAL PUBLIC LICENSE) WITH ALL RIGHTS AND
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 * LICENSES THEREUNDER. IF YOU HAVE RECEIVED THIS WORK DIRECTLY OR INDIRECTLY
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * FROM [GAIM] AS PART OF SUCH A REPUBLICATION, YOU HAVE ALL RIGHTS AND LICENSES
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 * GRANTED BY [GAIM] UNDER THE GPL. IN CONNECTION WITH SUCH A REPUBLICATION, IF
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * ANYTHING IN THIS NOTICE CONFLICTS WITH THE TERMS OF THE GPL, SUCH TERMS
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 * PREVAIL.
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 *
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 #include <glib.h>
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24 #include <string.h>
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25 #include "nmfield.h"
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26 #include "nmuser.h"
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27 #include "nmconn.h"
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 #include "nmcontact.h"
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 #include "nmuserrecord.h"
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30 #include "util.h"
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31
8684
046dd8ef2920 [gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents: 8675
diff changeset
32 /* This is the template that we wrap outgoing messages in, since the other
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 * GW Messenger clients expect messages to be in RTF.
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35 #define RTF_TEMPLATE "{\\rtf1\\fbidis\\ansi\\ansicpg1252\\deff0\\deflang1033"\
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36 "{\\fonttbl{\\f0\\fswiss\\fprq2\\fcharset0 "\
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
37 "Microsoft Sans Serif;}}\n{\\colortbl ;\\red0"\
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38 "\\green0\\blue0;}\n\\viewkind4\\uc1\\pard\\ltrpar"\
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39 "\\li50\\ri50\\cf1\\f0\\fs20 %s\\par\n}"
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41 static NMERR_T nm_process_response(NMUser * user);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43 static void _update_contact_list(NMUser * user, NMField * fields);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45 /**
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46 * See header for comments on on "public" functions
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47 */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49 NMUser *
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50 nm_initialize_user(const char *name, const char *server_addr,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51 int port, gpointer data, nm_event_cb event_callback)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52 {
8782
5a2b5e4abf3a [gaim-migrate @ 9544]
Christian Hammond <chipx86@chipx86.com>
parents: 8744
diff changeset
53 NMUser *user;
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54 if (name == NULL || server_addr == NULL || event_callback == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55 return NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56
8782
5a2b5e4abf3a [gaim-migrate @ 9544]
Christian Hammond <chipx86@chipx86.com>
parents: 8744
diff changeset
57 user = g_new0(NMUser, 1);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59 user->conn = g_new0(NMConn, 1);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61 user->contacts =
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62 g_hash_table_new_full(g_str_hash, nm_utf8_str_equal,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
63 g_free, (GDestroyNotify) nm_release_contact);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65 user->user_records =
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66 g_hash_table_new_full(g_str_hash, nm_utf8_str_equal, g_free,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67 (GDestroyNotify) nm_release_user_record);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
68
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69 user->display_id_to_dn = g_hash_table_new_full(g_str_hash, nm_utf8_str_equal,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70 g_free, g_free);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
72 user->name = g_strdup(name);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
73 user->conn->addr = g_strdup(server_addr);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
74 user->conn->port = port;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
75 user->evt_callback = event_callback;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76 user->client_data = data;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
77
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78 return user;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
82 void
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83 nm_deinitialize_user(NMUser * user)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
85 NMConn *conn = user->conn;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
86
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
87 g_free(conn->addr);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
88 g_free(conn);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
90 if (user->contacts) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
91 g_hash_table_destroy(user->contacts);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
92 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
93
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
94 if (user->user_records) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
95 g_hash_table_destroy(user->user_records);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
96 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
97
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
98 if (user->display_id_to_dn) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
99 g_hash_table_destroy(user->display_id_to_dn);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
100 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
101
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
102 if (user->name) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
103 g_free(user->name);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
104 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
105
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
106 if (user->user_record) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
107 nm_release_user_record(user->user_record);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
108 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
109
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110 nm_conference_list_free(user);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
111 nm_destroy_contact_list(user);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
112
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113 g_free(user);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
114 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
115
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116 NMERR_T
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
117 nm_send_login(NMUser * user, const char *pwd, const char *my_addr,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118 const char *user_agent, nm_response_cb callback, gpointer data)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
119 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120 NMERR_T rc = NM_OK;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
121 NMField *fields = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
122 NMRequest *req = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
123
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
124 if (user == NULL || pwd == NULL || user_agent == NULL) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
125 return NMERR_BAD_PARM;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
126 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
127
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128 fields = nm_add_field(fields, NM_A_SZ_USERID, 0, NMFIELD_METHOD_VALID, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129 (guint32) g_strdup(user->name), NMFIELD_TYPE_UTF8);
8684
046dd8ef2920 [gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents: 8675
diff changeset
130
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
131 fields = nm_add_field(fields, NM_A_SZ_CREDENTIALS, 0, NMFIELD_METHOD_VALID, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
132 (guint32) g_strdup(pwd), NMFIELD_TYPE_UTF8);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
134 fields = nm_add_field(fields, NM_A_SZ_USER_AGENT, 0, NMFIELD_METHOD_VALID, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
135 (guint32) g_strdup(user_agent), NMFIELD_TYPE_UTF8);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
136
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137 fields = nm_add_field(fields, NM_A_UD_BUILD, 0, NMFIELD_METHOD_VALID, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
138 (guint32) NM_PROTOCOL_VERSION,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
139 NMFIELD_TYPE_UDWORD);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
140 if (my_addr) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
141 fields = nm_add_field(fields, NM_A_IP_ADDRESS, 0, NMFIELD_METHOD_VALID, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
142 (guint32) g_strdup(my_addr), NMFIELD_TYPE_UTF8);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
143 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
144
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
145 /* Send the login */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
146 rc = nm_send_request(user->conn, "login", fields, &req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
147 if (rc == NM_OK && req != NULL) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
148 nm_request_set_callback(req, callback);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
149 nm_request_set_user_define(req, data);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
150 nm_conn_add_request_item(user->conn, req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
151 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
152
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
153 if (fields) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
154 nm_free_fields(&fields);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
155 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
156
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
157 if (req) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
158 nm_release_request(req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
159 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
160
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
161 return rc;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
162 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
163
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
164 NMERR_T
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
165 nm_send_set_status(NMUser * user, int status, const char *text,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
166 const char *auto_resp, nm_response_cb callback, gpointer data)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
167 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
168 NMERR_T rc = NM_OK;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
169 NMField *fields = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
170 NMRequest *req = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
171
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
172 if (user == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
173 return NMERR_BAD_PARM;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
174
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
175 /* Add the status */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
176 fields = nm_add_field(fields, NM_A_SZ_STATUS, 0, NMFIELD_METHOD_VALID, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
177 (guint32) g_strdup_printf("%d", status),
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
178 NMFIELD_TYPE_UTF8);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
179
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180 /* Add the status text and auto reply text if there is any */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
181 if (text) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182 fields = nm_add_field(fields, NM_A_SZ_STATUS_TEXT,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
183 0, NMFIELD_METHOD_VALID, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184 (guint32) g_strdup(text), NMFIELD_TYPE_UTF8);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
185 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
186
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
187 if (auto_resp) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
188 fields = nm_add_field(fields, NM_A_SZ_MESSAGE_BODY, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
189 NMFIELD_METHOD_VALID, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
190 (guint32) g_strdup(auto_resp), NMFIELD_TYPE_UTF8);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
191 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
192
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
193 rc = nm_send_request(user->conn, "setstatus", fields, &req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
194 if (rc == NM_OK && req) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
195 nm_request_set_callback(req, callback);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
196 nm_request_set_user_define(req, data);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
197 nm_conn_add_request_item(user->conn, req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
198 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
199
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
200 if (fields) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
201 nm_free_fields(&fields);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
202 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
203
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
204 if (req) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
205 nm_release_request(req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
206 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
207
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
208 return rc;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
209 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
210
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
211 NMERR_T
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
212 nm_send_get_details(NMUser * user, const char *name,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
213 nm_response_cb callback, gpointer data)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215 NMERR_T rc = NM_OK;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
216 NMField *fields = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
217 NMRequest *req = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
218
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
219 if (user == NULL || name == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
220 return NMERR_BAD_PARM;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
221
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
222 /* Add in DN or display id */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
223 if (strstr("=", name)) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
224 fields = nm_add_field(fields, NM_A_SZ_DN, 0, NMFIELD_METHOD_VALID, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
225 (guint32) g_strdup(name), NMFIELD_TYPE_DN);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
226 } else {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
227
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
228 const char *dn = nm_lookup_dn(user, name);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
229
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
230 if (dn) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
231 fields = nm_add_field(fields, NM_A_SZ_DN, 0, NMFIELD_METHOD_VALID, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
232 (guint32) g_strdup(name), NMFIELD_TYPE_DN);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
233 } else {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
234 fields =
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
235 nm_add_field(fields, NM_A_SZ_USERID, 0, NMFIELD_METHOD_VALID, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
236 (guint32) g_strdup(name), NMFIELD_TYPE_UTF8);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
237 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
238
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
239 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
240
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
241 rc = nm_send_request(user->conn, "getdetails", fields, &req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
242 if (rc == NM_OK) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
243 nm_request_set_callback(req, callback);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
244 nm_request_set_user_define(req, data);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
245 nm_conn_add_request_item(user->conn, req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
246 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
247
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
248 if (fields)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
249 nm_free_fields(&fields);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
250
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
251 if (req)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
252 nm_release_request(req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
253
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
254 return rc;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
255 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
256
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
257 NMERR_T
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
258 nm_send_create_conference(NMUser * user, NMConference * conference,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
259 nm_response_cb callback, gpointer message)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
260 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
261 NMERR_T rc = NM_OK;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
262 NMField *fields = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
263 NMField *tmp = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
264 NMField *field = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
265 NMRequest *req = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
266 int count, i;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
267
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
268 if (user == NULL || conference == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
269 return NMERR_BAD_PARM;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
270
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
271 /* Add in a blank guid */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
272 tmp = nm_add_field(tmp, NM_A_SZ_OBJECT_ID, 0, NMFIELD_METHOD_VALID, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
273 (guint32) g_strdup(BLANK_GUID), NMFIELD_TYPE_UTF8);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
274
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
275 fields = nm_add_field(fields, NM_A_FA_CONVERSATION, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
276 NMFIELD_METHOD_VALID, 0, (guint32) tmp,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
277 NMFIELD_TYPE_ARRAY);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
278 tmp = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
279
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
280 /* Add participants in */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
281 count = nm_conference_get_participant_count(conference);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
282 for (i = 0; i < count; i++) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
283 NMUserRecord *user_record = nm_conference_get_participant(conference, i);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
284
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
285 if (user_record) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
286 fields = nm_add_field(fields, NM_A_SZ_DN,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
287 0, NMFIELD_METHOD_VALID, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
288 (guint32)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
289 g_strdup(nm_user_record_get_dn(user_record)),
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
290 NMFIELD_TYPE_DN);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
291 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
292 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
293
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
294 /* Add our user in */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
295 field = nm_locate_field(NM_A_SZ_DN, user->fields);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
296 if (field) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
297 fields = nm_add_field(fields, NM_A_SZ_DN,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
298 0, NMFIELD_METHOD_VALID, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
299 (guint32) g_strdup((char *) field->value),
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
300 NMFIELD_TYPE_DN);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
301 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
302
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
303 rc = nm_send_request(user->conn, "createconf", fields, &req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
304 if (rc == NM_OK && req) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
305 nm_request_set_callback(req, callback);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
306 nm_request_set_data(req, conference);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
307 nm_request_set_user_define(req, message);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
308 nm_conn_add_request_item(user->conn, req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
309 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
310
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
311 if (req)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
312 nm_release_request(req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
313
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
314 if (fields)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
315 nm_free_fields(&fields);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
316
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
317 return rc;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
318 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
319
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
320 NMERR_T
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
321 nm_send_leave_conference(NMUser * user, NMConference * conference,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
322 nm_response_cb callback, gpointer message)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
323 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
324
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
325 NMERR_T rc = NM_OK;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
326 NMField *fields = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
327 NMField *tmp = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
328 NMRequest *req = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
329
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
330 if (user == NULL || conference == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
331 return NMERR_BAD_PARM;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
332
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
333 /* Add in the conference guid */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
334 tmp = nm_add_field(tmp, NM_A_SZ_OBJECT_ID, 0, NMFIELD_METHOD_VALID, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
335 (guint32) g_strdup(nm_conference_get_guid(conference)),
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
336 NMFIELD_TYPE_UTF8);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
337
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
338 fields = nm_add_field(fields, NM_A_FA_CONVERSATION, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
339 NMFIELD_METHOD_VALID, 0, (guint32) tmp,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
340 NMFIELD_TYPE_ARRAY);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
341 tmp = NULL;
8684
046dd8ef2920 [gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents: 8675
diff changeset
342
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
343 /* Send the request to the server */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
344 rc = nm_send_request(user->conn, "leaveconf", fields, &req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
345 if (rc == NM_OK && req) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
346 nm_request_set_callback(req, callback);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
347 nm_request_set_data(req, conference);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
348 nm_request_set_user_define(req, message);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
349 nm_conn_add_request_item(user->conn, req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
350 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
351
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
352 if (req)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
353 nm_release_request(req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
354
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
355 if (fields)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
356 nm_free_fields(&fields);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
357
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
358 return rc;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
359 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
360
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
361 NMERR_T
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
362 nm_send_join_conference(NMUser * user, NMConference * conference,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
363 nm_response_cb callback, gpointer data)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
364 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
365 NMERR_T rc = NM_OK;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
366 NMField *fields = NULL, *tmp = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
367 NMRequest *req = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
368
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
369 if (user == NULL || conference == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
370 return NMERR_BAD_PARM;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
371
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
372 /* Add in the conference guid */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
373 tmp = nm_add_field(tmp, NM_A_SZ_OBJECT_ID, 0, NMFIELD_METHOD_VALID, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
374 (guint32) g_strdup(nm_conference_get_guid(conference)),
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
375 NMFIELD_TYPE_UTF8);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
376
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
377 fields = nm_add_field(fields, NM_A_FA_CONVERSATION, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
378 NMFIELD_METHOD_VALID, 0, (guint32) tmp,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
379 NMFIELD_TYPE_ARRAY);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
380 tmp = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
381
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
382 /* Send the request to the server */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
383 rc = nm_send_request(user->conn, "joinconf", fields, &req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
384
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
385 /* Set up the request object so that we know what to do
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
386 * when we get a response
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
387 */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
388 if (rc == NM_OK && req) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
389 nm_request_set_callback(req, callback);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
390 nm_request_set_data(req, conference);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
391 nm_request_set_user_define(req, data);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
392 nm_conn_add_request_item(user->conn, req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
393 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
394
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
395 if (req)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
396 nm_release_request(req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
397
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
398 if (fields)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
399 nm_free_fields(&fields);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
400
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
401 return rc;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
402 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
403
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
404 NMERR_T
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
405 nm_send_reject_conference(NMUser * user, NMConference * conference,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
406 nm_response_cb callback, gpointer data)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
407 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
408 NMERR_T rc = NM_OK;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
409 NMField *fields = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
410 NMField *tmp = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
411 NMRequest *req = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
412
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
413 if (user == NULL || conference == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
414 return NMERR_BAD_PARM;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
415
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
416 /* Add in the conference guid */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
417 tmp = nm_add_field(tmp, NM_A_SZ_OBJECT_ID, 0, NMFIELD_METHOD_VALID, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
418 (guint32) g_strdup(nm_conference_get_guid(conference)),
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
419 NMFIELD_TYPE_UTF8);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
420
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
421 fields = nm_add_field(fields, NM_A_FA_CONVERSATION, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
422 NMFIELD_METHOD_VALID, 0, (guint32) tmp,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
423 NMFIELD_TYPE_ARRAY);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
424 tmp = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
425
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
426 /* Send the request to the server */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
427 rc = nm_send_request(user->conn, "rejectconf", fields, &req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
428
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
429 /* Set up the request object so that we know what to do
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
430 * when we get a response
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
431 */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
432 if (rc == NM_OK && req) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
433 nm_request_set_callback(req, callback);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
434 nm_request_set_data(req, conference);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
435 nm_request_set_user_define(req, data);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
436 nm_conn_add_request_item(user->conn, req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
437 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
438
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
439 if (req)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
440 nm_release_request(req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
441
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
442 if (fields)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
443 nm_free_fields(&fields);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
444
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
445 return rc;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
446 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
447
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
448 NMERR_T
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
449 nm_send_message(NMUser * user, NMMessage * message, nm_response_cb callback)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
450 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
451 NMERR_T rc = NM_OK;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
452 const char *text;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
453 NMField *fields = NULL, *tmp = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
454 NMRequest *req = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
455 NMConference *conf;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
456 NMUserRecord *user_record;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
457 int count, i;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
458
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
459 if (user == NULL || message == NULL) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
460 return NMERR_BAD_PARM;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
461 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
462
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
463 conf = nm_message_get_conference(message);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
464 if (!nm_conference_is_instantiated(conf)) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
465 rc = NMERR_CONFERENCE_NOT_INSTANTIATED;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
466 } else {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
467
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
468 tmp = nm_add_field(tmp, NM_A_SZ_OBJECT_ID, 0, NMFIELD_METHOD_VALID, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
469 (guint32) g_strdup(nm_conference_get_guid(conf)),
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
470 NMFIELD_TYPE_UTF8);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
471
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
472 fields =
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
473 nm_add_field(fields, NM_A_FA_CONVERSATION, 0, NMFIELD_METHOD_VALID, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
474 (guint32) tmp, NMFIELD_TYPE_ARRAY);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
475 tmp = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
476
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
477 /* Add RTF and plain text versions of the message */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
478 text = nm_message_get_text(message);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
479
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
480 tmp = nm_add_field(tmp, NM_A_SZ_MESSAGE_BODY, 0, NMFIELD_METHOD_VALID, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
481 (guint32) g_strdup_printf(RTF_TEMPLATE, text),
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
482 NMFIELD_TYPE_UTF8);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
483
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
484 tmp = nm_add_field(tmp, NM_A_UD_MESSAGE_TYPE, 0, NMFIELD_METHOD_VALID, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
485 (guint32) 0, NMFIELD_TYPE_UDWORD);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
486
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
487 tmp = nm_add_field(tmp, NM_A_SZ_MESSAGE_TEXT, 0, NMFIELD_METHOD_VALID, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
488 (guint32) g_strdup(text), NMFIELD_TYPE_UTF8);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
489
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
490 fields = nm_add_field(fields, NM_A_FA_MESSAGE, 0, NMFIELD_METHOD_VALID, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
491 (guint32) tmp, NMFIELD_TYPE_ARRAY);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
492 tmp = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
493
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
494 /* Add participants */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
495 count = nm_conference_get_participant_count(conf);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
496 for (i = 0; i < count; i++) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
497 user_record = nm_conference_get_participant(conf, i);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
498 if (user_record) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
499 fields =
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
500 nm_add_field(fields, NM_A_SZ_DN, 0, NMFIELD_METHOD_VALID, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
501 (guint32)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
502 g_strdup(nm_user_record_get_dn(user_record)),
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
503 NMFIELD_TYPE_DN);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
504 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
505 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
506
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
507 /* Send the request */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
508 rc = nm_send_request(user->conn, "sendmessage", fields, &req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
509 if (rc == NM_OK && req) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
510 nm_request_set_callback(req, callback);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
511 nm_conn_add_request_item(user->conn, req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
512 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
513 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
514
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
515 if (fields) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
516 nm_free_fields(&fields);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
517 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
518
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
519 if (req) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
520 nm_release_request(req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
521 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
522
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
523 return rc;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
524 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
525
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
526 NMERR_T
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
527 nm_send_typing(NMUser * user, NMConference * conf,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
528 gboolean typing, nm_response_cb callback)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
529 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
530 NMERR_T rc = NM_OK;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
531 char *str = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
532 NMField *fields = NULL, *tmp = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
533 NMRequest *req = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
534
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
535 if (user == NULL || conf == NULL) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
536 return NMERR_BAD_PARM;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
537 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
538
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
539 if (!nm_conference_is_instantiated(conf)) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
540 rc = NMERR_CONFERENCE_NOT_INSTANTIATED;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
541 } else {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
542 /* Add the conference GUID */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
543 tmp = nm_add_field(tmp, NM_A_SZ_OBJECT_ID, 0, NMFIELD_METHOD_VALID, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
544 (guint32) g_strdup(nm_conference_get_guid(conf)),
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
545 NMFIELD_TYPE_UTF8);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
546
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
547 /* Add typing type */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
548 str = g_strdup_printf("%d",
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
549 (typing ? NMEVT_USER_TYPING :
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
550 NMEVT_USER_NOT_TYPING));
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
551
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
552 tmp = nm_add_field(tmp, NM_A_SZ_TYPE, 0, NMFIELD_METHOD_VALID, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
553 (guint32) str, NMFIELD_TYPE_UTF8);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
554
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
555 fields =
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
556 nm_add_field(fields, NM_A_FA_CONVERSATION, 0, NMFIELD_METHOD_VALID, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
557 (guint32) tmp, NMFIELD_TYPE_ARRAY);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
558 tmp = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
559
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
560 rc = nm_send_request(user->conn, "sendtyping", fields, &req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
561 if (rc == NM_OK && req) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
562 nm_request_set_callback(req, callback);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
563 nm_conn_add_request_item(user->conn, req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
564 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
565 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
566
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
567 if (req)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
568 nm_release_request(req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
569
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
570 if (fields)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
571 nm_free_fields(&fields);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
572
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
573 return rc;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
574 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
575
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
576 NMERR_T
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
577 nm_send_create_contact(NMUser * user, NMFolder * folder,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
578 NMContact * contact, nm_response_cb callback,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
579 gpointer data)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
580 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
581 NMERR_T rc = NM_OK;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
582 NMField *fields = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
583 NMRequest *req = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
584 const char *name = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
585 const char *display_name = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
586
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
587 if (user == NULL || folder == NULL || contact == NULL) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
588 return NMERR_BAD_PARM;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
589 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
590
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
591 /* Add parent ID */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
592 fields = nm_add_field(fields, NM_A_SZ_PARENT_ID, 0, NMFIELD_METHOD_VALID, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
593 (guint32) g_strdup_printf("%d",
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
594 nm_folder_get_id(folder)),
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
595 NMFIELD_TYPE_UTF8);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
596
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
597 /* Check to see if userid is current user and return an error? */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
598
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
599 /* Check to see if contact already exists and return an error? */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
600
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
601 /* Add userid or dn */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
602 name = nm_contact_get_dn(contact);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
603 if (name == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
604 return NMERR_BAD_PARM;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
605
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
606 if (strstr("=", name)) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
607 fields = nm_add_field(fields, NM_A_SZ_DN, 0, NMFIELD_METHOD_VALID, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
608 (guint32) g_strdup(name), NMFIELD_TYPE_DN);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
609 } else {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
610 fields = nm_add_field(fields, NM_A_SZ_USERID, 0, NMFIELD_METHOD_VALID, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
611 (guint32) g_strdup(name), NMFIELD_TYPE_UTF8);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
612 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
613
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
614 /* Add display name */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
615 display_name = nm_contact_get_display_name(contact);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
616 if (display_name)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
617 fields = nm_add_field(fields, NM_A_SZ_DISPLAY_NAME, 0, NMFIELD_METHOD_VALID, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
618 (guint32) g_strdup(display_name), NMFIELD_TYPE_UTF8);
8684
046dd8ef2920 [gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents: 8675
diff changeset
619
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
620 /* Dispatch the request */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
621 rc = nm_send_request(user->conn, "createcontact", fields, &req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
622 if (rc == NM_OK && req) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
623 nm_request_set_callback(req, callback);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
624 nm_request_set_data(req, contact);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
625 nm_request_set_user_define(req, data);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
626 nm_conn_add_request_item(user->conn, req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
627 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
628
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
629 if (fields)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
630 nm_free_fields(&fields);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
631
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
632 if (req)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
633 nm_release_request(req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
634
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
635 return rc;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
636 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
637
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
638 NMERR_T
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
639 nm_send_remove_contact(NMUser * user, NMFolder * folder,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
640 NMContact * contact, nm_response_cb callback,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
641 gpointer data)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
642 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
643 NMERR_T rc = NM_OK;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
644 NMField *fields = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
645 NMRequest *req = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
646
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
647 if (user == NULL || folder == NULL || contact == NULL) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
648 return NMERR_BAD_PARM;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
649 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
650
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
651 /* Add parent id */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
652 fields = nm_add_field(fields, NM_A_SZ_PARENT_ID, 0, NMFIELD_METHOD_VALID, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
653 (guint32) g_strdup_printf("%d",
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
654 nm_folder_get_id(folder)),
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
655 NMFIELD_TYPE_UTF8);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
656
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
657 /* Add object id */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
658 fields = nm_add_field(fields, NM_A_SZ_OBJECT_ID, 0, NMFIELD_METHOD_VALID, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
659 (guint32) g_strdup_printf("%d",
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
660 nm_contact_get_id(contact)),
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
661 NMFIELD_TYPE_UTF8);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
662
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
663 /* Dispatch the request */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
664 rc = nm_send_request(user->conn, "deletecontact", fields, &req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
665 if (rc == NM_OK && req) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
666 nm_request_set_callback(req, callback);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
667 nm_request_set_data(req, contact);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
668 nm_request_set_user_define(req, data);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
669 nm_conn_add_request_item(user->conn, req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
670 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
671
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
672 if (fields)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
673 nm_free_fields(&fields);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
674
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
675 if (req)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
676 nm_release_request(req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
677
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
678 return rc;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
679 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
680
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
681 NMERR_T
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
682 nm_send_create_folder(NMUser * user, const char *name,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
683 nm_response_cb callback, gpointer data)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
684 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
685 NMERR_T rc = NM_OK;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
686 NMField *fields = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
687 NMRequest *req = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
688
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
689 if (user == NULL || name == NULL) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
690 return NMERR_BAD_PARM;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
691 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
692
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
693 /* Add parent ID */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
694 fields = nm_add_field(fields, NM_A_SZ_PARENT_ID, 0, NMFIELD_METHOD_VALID, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
695 (guint32) g_strdup("0"), NMFIELD_TYPE_UTF8);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
696
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
697 /* Add name of the folder to add */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
698 fields =
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
699 nm_add_field(fields, NM_A_SZ_DISPLAY_NAME, 0, NMFIELD_METHOD_VALID, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
700 (guint32) g_strdup(name), NMFIELD_TYPE_UTF8);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
701
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
702 /* Add sequence, for now just put it at the bottom */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
703 fields =
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
704 nm_add_field(fields, NM_A_SZ_SEQUENCE_NUMBER, 0, NMFIELD_METHOD_VALID, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
705 (guint32) g_strdup("-1"), NMFIELD_TYPE_UTF8);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
706
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
707 /* Dispatch the request */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
708 rc = nm_send_request(user->conn, "createfolder", fields, &req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
709 if (rc == NM_OK && req) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
710 nm_request_set_callback(req, callback);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
711 nm_request_set_data(req, g_strdup(name));
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
712 nm_request_set_user_define(req, data);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
713 nm_conn_add_request_item(user->conn, req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
714 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
715
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
716 if (fields)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
717 nm_free_fields(&fields);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
718
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
719 if (req)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
720 nm_release_request(req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
721
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
722 return rc;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
723 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
724
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
725 NMERR_T
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
726 nm_send_remove_folder(NMUser * user, NMFolder * folder,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
727 nm_response_cb callback, gpointer data)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
728 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
729 NMERR_T rc = NM_OK;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
730 NMField *fields = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
731 NMRequest *req = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
732
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
733 if (user == NULL || folder == NULL) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
734 return NMERR_BAD_PARM;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
735 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
736
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
737 /* Add the object id */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
738 fields = nm_add_field(fields, NM_A_SZ_OBJECT_ID, 0, NMFIELD_METHOD_VALID, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
739 (guint32) g_strdup_printf("%d", nm_folder_get_id(folder)),
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
740 NMFIELD_TYPE_UTF8);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
741
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
742 /* Dispatch the request */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
743 rc = nm_send_request(user->conn, "deletecontact", fields, &req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
744 if (rc == NM_OK && req) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
745 nm_request_set_callback(req, callback);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
746 nm_request_set_data(req, folder);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
747 nm_request_set_user_define(req, data);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
748 nm_conn_add_request_item(user->conn, req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
749 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
750
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
751 if (fields)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
752 nm_free_fields(&fields);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
753
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
754 if (req)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
755 nm_release_request(req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
756
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
757 return rc;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
758 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
759
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
760 NMERR_T
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
761 nm_send_get_status(NMUser * user, NMUserRecord * user_record,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
762 nm_response_cb callback, gpointer data)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
763 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
764 NMERR_T rc = NM_OK;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
765 NMField *fields = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
766 NMRequest *req = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
767 const char *dn;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
768
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
769 if (user == NULL || user_record == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
770 return NMERR_BAD_PARM;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
771
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
772 /* Add DN to field list */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
773 dn = nm_user_record_get_dn(user_record);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
774 if (dn == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
775 return (NMERR_T) -1;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
776
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
777 fields = nm_add_field(fields, NM_A_SZ_DN, 0, NMFIELD_METHOD_VALID, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
778 (guint32) g_strdup(dn), NMFIELD_TYPE_UTF8);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
779
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
780 /* Dispatch the request */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
781 rc = nm_send_request(user->conn, "getstatus", fields, &req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
782 if (rc == NM_OK && req) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
783 nm_request_set_callback(req, callback);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
784 nm_request_set_data(req, user_record);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
785 nm_request_set_user_define(req, data);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
786 nm_conn_add_request_item(user->conn, req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
787 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
788
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
789 if (fields)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
790 nm_free_fields(&fields);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
791
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
792 if (req)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
793 nm_release_request(req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
794
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
795 return rc;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
796 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
797
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
798 NMERR_T
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
799 nm_send_rename_contact(NMUser * user, NMContact * contact,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
800 const char *new_name, nm_response_cb callback,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
801 gpointer data)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
802 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
803 NMERR_T rc = NM_OK;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
804 NMField *field = NULL, *fields = NULL, *list = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
805 NMRequest *req = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
806
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
807 if (user == NULL || contact == NULL || new_name == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
808 return NMERR_BAD_PARM;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
809
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
810 /* Create field list for current contact */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
811 field = nm_contact_to_fields(contact);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
812 if (field) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
813
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
814 fields =
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
815 nm_add_field(fields, NM_A_FA_CONTACT, 0, NMFIELD_METHOD_DELETE, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
816 (guint32) field, NMFIELD_TYPE_ARRAY);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
817 field = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
818
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
819 /* Update the contacts display name locally */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
820 nm_contact_set_display_name(contact, new_name);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
821
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
822 /* Create field list for updated contact */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
823 field = nm_contact_to_fields(contact);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
824 if (field) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
825 fields =
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
826 nm_add_field(fields, NM_A_FA_CONTACT, 0, NMFIELD_METHOD_ADD, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
827 (guint32) field, NMFIELD_TYPE_ARRAY);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
828 field = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
829
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
830 /* Package it up */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
831 list =
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
832 nm_add_field(list, NM_A_FA_CONTACT_LIST, 0, NMFIELD_METHOD_VALID,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
833 0, (guint32) fields, NMFIELD_TYPE_ARRAY);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
834 fields = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
835
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
836 rc = nm_send_request(user->conn, "updateitem", list, &req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
837 if (rc == NM_OK && req) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
838 nm_request_set_callback(req, callback);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
839 nm_request_set_data(req, contact);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
840 nm_request_set_user_define(req, data);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
841 nm_conn_add_request_item(user->conn, req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
842 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
843 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
844 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
845
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
846 if (list)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
847 nm_free_fields(&list);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
848
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
849 return rc;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
850 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
851
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
852 NMERR_T
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
853 nm_send_rename_folder(NMUser * user, NMFolder * folder, const char *new_name,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
854 nm_response_cb callback, gpointer data)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
855 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
856 NMERR_T rc = NM_OK;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
857 NMField *field = NULL, *fields = NULL, *list = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
858 NMRequest *req = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
859
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
860 if (user == NULL || folder == NULL || new_name == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
861 return NMERR_BAD_PARM;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
862
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
863 /* Make sure folder does not already exist!? */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
864 if (nm_find_folder(user, new_name))
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
865 return NMERR_FOLDER_EXISTS;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
866
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
867 /* Create field list for current folder */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
868 field = nm_folder_to_fields(folder);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
869 if (field) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
870
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
871 fields = nm_add_field(fields, NM_A_FA_FOLDER, 0, NMFIELD_METHOD_DELETE, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
872 (guint32) field, NMFIELD_TYPE_ARRAY);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
873 field = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
874
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
875 /* Update the folders display name locally */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
876 nm_folder_set_name(folder, new_name);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
877
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
878 /* Create field list for updated folder */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
879 field = nm_folder_to_fields(folder);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
880 if (field) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
881 fields =
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
882 nm_add_field(fields, NM_A_FA_FOLDER, 0, NMFIELD_METHOD_ADD, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
883 (guint32) field, NMFIELD_TYPE_ARRAY);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
884 field = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
885
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
886 /* Package it up */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
887 list =
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
888 nm_add_field(list, NM_A_FA_CONTACT_LIST, 0, NMFIELD_METHOD_VALID,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
889 0, (guint32) fields, NMFIELD_TYPE_ARRAY);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
890 fields = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
891
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
892 rc = nm_send_request(user->conn, "updateitem", list, &req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
893 if (rc == NM_OK && req) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
894 nm_request_set_callback(req, callback);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
895 nm_request_set_data(req, folder);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
896 nm_request_set_user_define(req, data);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
897 nm_conn_add_request_item(user->conn, req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
898 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
899 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
900 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
901
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
902 if (list)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
903 nm_free_fields(&list);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
904
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
905 return rc;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
906 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
907
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
908 NMERR_T
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
909 nm_send_move_contact(NMUser * user, NMContact * contact, NMFolder * folder,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
910 nm_response_cb callback, gpointer data)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
911 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
912 NMERR_T rc = NM_OK;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
913 NMField *field = NULL, *fields = NULL, *list = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
914 NMRequest *req = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
915
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
916 if (user == NULL || contact == NULL || folder == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
917 return NMERR_BAD_PARM;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
918
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
919 /* Create field list for the contact */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
920 field = nm_contact_to_fields(contact);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
921 if (field) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
922
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
923 fields =
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
924 nm_add_field(fields, NM_A_FA_CONTACT, 0, NMFIELD_METHOD_DELETE, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
925 (guint32) field, NMFIELD_TYPE_ARRAY);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
926 field = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
927
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
928 /* Wrap the contact up and add it to the request field list */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
929 list =
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
930 nm_add_field(list, NM_A_FA_CONTACT_LIST, 0, NMFIELD_METHOD_VALID, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
931 (guint32) fields, NMFIELD_TYPE_ARRAY);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
932 fields = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
933
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
934 /* Add sequence number */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
935 list =
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
936 nm_add_field(list, NM_A_SZ_SEQUENCE_NUMBER, 0, NMFIELD_METHOD_VALID,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
937 0, (guint32) g_strdup("-1"), NMFIELD_TYPE_UTF8);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
938
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
939 /* Add parent ID */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
940 list = nm_add_field(list, NM_A_SZ_PARENT_ID, 0, NMFIELD_METHOD_VALID, 0,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
941 (guint32) g_strdup_printf("%d",
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
942 nm_folder_get_id(folder)),
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
943 NMFIELD_TYPE_UTF8);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
944
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
945 /* Dispatch the request */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
946 rc = nm_send_request(user->conn, "movecontact", list, &req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
947 if (rc == NM_OK && req) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
948 nm_request_set_callback(req, callback);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
949 nm_request_set_data(req, contact);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
950 nm_request_set_user_define(req, data);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
951 nm_conn_add_request_item(user->conn, req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
952
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
953 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
954 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
955
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
956 if (list)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
957 nm_free_fields(&list);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
958
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
959 return rc;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
960 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
961
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
962
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
963 NMERR_T
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
964 nm_process_new_data(NMUser * user)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
965 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
966 NMConn *conn;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
967 NMERR_T rc = NM_OK;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
968 int ret;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
969 guint32 val;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
970
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
971 if (user == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
972 return NMERR_BAD_PARM;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
973
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
974 conn = user->conn;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
975
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
976 /* Check to see if this is an event or a response */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
977 ret = nm_tcp_read(conn, (char *) &val, sizeof(val));
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
978 if (ret == sizeof(val)) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
979
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
980 if (strncmp((char *) &val, "HTTP", strlen("HTTP")) == 0)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
981 rc = nm_process_response(user);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
982 else
8874
a2affcdf8e01 [gaim-migrate @ 9643]
Luke Schierer <lschiere@pidgin.im>
parents: 8782
diff changeset
983 rc = nm_process_event(user, GUINT32_FROM_LE(val));
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
984
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
985 } else {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
986 rc = NMERR_PROTOCOL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
987 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
988
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
989 return rc;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
990 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
991
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
992 NMConference *
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
993 nm_find_conversation(NMUser * user, const char *who)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
994 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
995 NMConference *conference = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
996 NMConference *tmp;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
997 GSList *cnode;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
998
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
999 if (user && user->conferences) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1000 for (cnode = user->conferences; cnode; cnode = cnode->next) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1001 tmp = cnode->data;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1002 if (nm_conference_get_participant_count(tmp) == 1) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1003 NMUserRecord *ur = nm_conference_get_participant(tmp, 0);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1004
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1005 if (ur) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1006 if (nm_utf8_str_equal(nm_user_record_get_dn(ur), who)) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1007 conference = tmp;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1008 break;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1009 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1010 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1011 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1012 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1013 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1014
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1015 return conference;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1016 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1017
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1018 void
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1019 nm_conference_list_add(NMUser * user, NMConference * conf)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1020 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1021 if (user == NULL || conf == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1022 return;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1023
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1024 nm_conference_add_ref(conf);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1025 user->conferences = g_slist_append(user->conferences, conf);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1026 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1027
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1028 void
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1029 nm_conference_list_remove(NMUser * user, NMConference * conf)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1030 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1031 if (user == NULL || conf == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1032 return;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1033
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1034 if (g_slist_find(user->conferences, conf)) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1035 user->conferences = g_slist_remove(user->conferences, conf);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1036 nm_release_conference(conf);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1037 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1038 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1039
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1040 void
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1041 nm_conference_list_free(NMUser * user)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1042 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1043 GSList *cnode;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1044 NMConference *conference;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1045
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1046 if (user == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1047 return;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1048
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1049 if (user->conferences) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1050 for (cnode = user->conferences; cnode; cnode = cnode->next) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1051 conference = cnode->data;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1052 cnode->data = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1053 nm_release_conference(conference);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1054 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1055
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1056 g_slist_free(user->conferences);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1057 user->conferences = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1058 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1059 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1060
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1061 NMConference *
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1062 nm_conference_list_find(NMUser * user, const char *guid)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1063 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1064 GSList *cnode;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1065 NMConference *conference = NULL, *tmp;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1066
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1067 if (user == NULL || guid == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1068 return NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1069
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1070 if (user->conferences) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1071 for (cnode = user->conferences; cnode; cnode = cnode->next) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1072 tmp = cnode->data;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1073 if (nm_are_guids_equal(nm_conference_get_guid(tmp), guid)) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1074 conference = tmp;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1075 break;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1076 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1077 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1078 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1079
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1080 return conference;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1081 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1082
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1083 gboolean
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1084 nm_are_guids_equal(const char *guid1, const char *guid2)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1085 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1086 if (guid1 == NULL || guid2 == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1087 return FALSE;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1088
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1089 return (strncmp(guid1, guid2, CONF_GUID_END) == 0);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1090 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1091
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1092 void
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1093 nm_user_add_contact(NMUser * user, NMContact * contact)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1094 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1095 if (user == NULL || contact == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1096 return;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1097
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1098 nm_contact_add_ref(contact);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1099
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1100 g_hash_table_insert(user->contacts,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1101 g_utf8_strdown(nm_contact_get_dn(contact), -1), contact);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1102 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1103
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1104 void
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1105 nm_user_add_user_record(NMUser * user, NMUserRecord * user_record)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1106 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1107 nm_user_record_add_ref(user_record);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1108
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1109 g_hash_table_insert(user->user_records,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1110 g_utf8_strdown(nm_user_record_get_dn(user_record), -1),
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1111 user_record);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1112
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1113 g_hash_table_insert(user->display_id_to_dn,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1114 g_utf8_strdown(nm_user_record_get_display_id(user_record),
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1115 -1),
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1116 g_utf8_strdown(nm_user_record_get_dn(user_record), -1));
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1117
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1118 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1119
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1120 nm_event_cb
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1121 nm_user_get_event_callback(NMUser * user)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1122 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1123 if (user == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1124 return NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1125
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1126 return user->evt_callback;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1127 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1128
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1129 NMConn *
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1130 nm_user_get_conn(NMUser * user)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1131 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1132 if (user == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1133 return NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1134
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1135 return user->conn;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1136 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1137
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1138 NMERR_T
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1139 nm_create_contact_list(NMUser * user)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1140 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1141 NMERR_T rc = NM_OK;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1142 NMField *locate = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1143
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1144 if (user == NULL || user->fields == NULL) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1145 return NMERR_BAD_PARM;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1146 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1147
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1148 /* Create the root folder */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1149 user->root_folder = nm_create_folder("");
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1150
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1151 /* Find the contact list in the login fields */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1152 locate = nm_locate_field(NM_A_FA_CONTACT_LIST, user->fields);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1153 if (locate != NULL) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1154
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1155 /* Add the folders and then the contacts */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1156 nm_folder_add_contacts_and_folders(user, user->root_folder,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1157 (NMField *) (locate->value));
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1158
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1159 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1160
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1161 return rc;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1162 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1163
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1164 void
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1165 nm_destroy_contact_list(NMUser * user)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1166 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1167 if (user == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1168 return;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1169
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1170 if (user->root_folder) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1171 nm_release_folder(user->root_folder);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1172 user->root_folder = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1173 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1174 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1175
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1176 NMFolder *
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1177 nm_get_root_folder(NMUser * user)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1178 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1179 if (user == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1180 return NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1181
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1182 if (user->root_folder == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1183 nm_create_contact_list(user);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1184
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1185 return user->root_folder;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1186 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1187
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1188 NMContact *
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1189 nm_find_contact(NMUser * user, const char *name)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1190 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1191 char *str;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1192 const char *dn = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1193 NMContact *contact = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1194
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1195 if (user == NULL || name == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1196 return NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1197
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1198 str = g_utf8_strdown(name, -1);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1199 if (strstr(str, "=")) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1200 dn = str;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1201 } else {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1202 /* Assume that we have a display id instead of a dn */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1203 dn = (const char *) g_hash_table_lookup(user->display_id_to_dn, str);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1204 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1205
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1206 /* Find contact object in reference table */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1207 if (dn) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1208 contact = (NMContact *) g_hash_table_lookup(user->contacts, dn);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1209 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1210
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1211 g_free(str);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1212 return contact;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1213 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1214
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1215 GList *
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1216 nm_find_contacts(NMUser * user, const char *dn)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1217 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1218 guint32 i, cnt;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1219 NMFolder *folder;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1220 NMContact *contact;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1221 GList *contacts = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1222
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1223 if (user == NULL || dn == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1224 return NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1225
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1226 /* Check for contact at the root */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1227 contact = nm_folder_find_contact(user->root_folder, dn);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1228 if (contact) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1229 contacts = g_list_append(contacts, contact);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1230 contact = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1231 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1232
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1233 /* Check for contact in each subfolder */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1234 cnt = nm_folder_get_subfolder_count(user->root_folder);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1235 for (i = 0; i < cnt; i++) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1236 folder = nm_folder_get_subfolder(user->root_folder, i);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1237 contact = nm_folder_find_contact(folder, dn);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1238 if (contact) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1239 contacts = g_list_append(contacts, contact);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1240 contact = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1241 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1242 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1243
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1244 return contacts;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1245 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1246
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1247 NMUserRecord *
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1248 nm_find_user_record(NMUser * user, const char *name)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1249 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1250 char *str = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1251 const char *dn = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1252 NMUserRecord *user_record = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1253
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1254 if (user == NULL || name == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1255 return NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1256
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1257 str = g_utf8_strdown(name, -1);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1258 if (strstr(str, "=")) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1259 dn = str;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1260 } else {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1261 /* Assume that we have a display id instead of a dn */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1262 dn = (const char *) g_hash_table_lookup(user->display_id_to_dn, str);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1263 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1264
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1265 /* Find user record in reference table */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1266 if (dn) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1267 user_record =
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1268 (NMUserRecord *) g_hash_table_lookup(user->user_records, dn);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1269 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1270
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1271 g_free(str);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1272 return user_record;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1273 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1274
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1275 const char *
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1276 nm_lookup_dn(NMUser * user, const char *display_id)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1277 {
8744
0f73e8204529 [gaim-migrate @ 9499]
Luke Schierer <lschiere@pidgin.im>
parents: 8684
diff changeset
1278 const char *dn;
0f73e8204529 [gaim-migrate @ 9499]
Luke Schierer <lschiere@pidgin.im>
parents: 8684
diff changeset
1279 char *lower;
0f73e8204529 [gaim-migrate @ 9499]
Luke Schierer <lschiere@pidgin.im>
parents: 8684
diff changeset
1280
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1281 if (user == NULL || display_id == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1282 return NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1283
8744
0f73e8204529 [gaim-migrate @ 9499]
Luke Schierer <lschiere@pidgin.im>
parents: 8684
diff changeset
1284 lower = g_utf8_strdown(display_id, -1);
0f73e8204529 [gaim-migrate @ 9499]
Luke Schierer <lschiere@pidgin.im>
parents: 8684
diff changeset
1285 dn = g_hash_table_lookup(user->display_id_to_dn, lower);
0f73e8204529 [gaim-migrate @ 9499]
Luke Schierer <lschiere@pidgin.im>
parents: 8684
diff changeset
1286 g_free(lower);
0f73e8204529 [gaim-migrate @ 9499]
Luke Schierer <lschiere@pidgin.im>
parents: 8684
diff changeset
1287
0f73e8204529 [gaim-migrate @ 9499]
Luke Schierer <lschiere@pidgin.im>
parents: 8684
diff changeset
1288 return dn;
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1289 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1290
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1291 NMFolder *
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1292 nm_find_folder(NMUser * user, const char *name)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1293 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1294 NMFolder *folder = NULL, *temp;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1295 int i, num_folders;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1296 const char *tname = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1297
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1298 if (user == NULL || name == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1299 return NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1300
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1301 if (*name == '\0')
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1302 return user->root_folder;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1303
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1304 num_folders = nm_folder_get_subfolder_count(user->root_folder);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1305 for (i = 0; i < num_folders; i++) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1306 temp = nm_folder_get_subfolder(user->root_folder, i);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1307 tname = nm_folder_get_name(temp);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1308
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1309 if (tname && (strcmp(tname, name) == 0)) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1310 folder = temp;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1311 break;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1312 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1313 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1314
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1315 return folder;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1316 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1317
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1318 NMFolder *
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1319 nm_find_folder_by_id(NMUser * user, int object_id)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1320 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1321 NMFolder *folder = NULL, *temp;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1322 int i, num_folders;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1323
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1324 if (user == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1325 return NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1326
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1327 if (object_id == 0)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1328 return user->root_folder;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1329
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1330 num_folders = nm_folder_get_subfolder_count(user->root_folder);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1331 for (i = 0; i < num_folders; i++) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1332 temp = nm_folder_get_subfolder(user->root_folder, i);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1333 if (nm_folder_get_id(temp) == object_id) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1334 folder = temp;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1335 break;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1336 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1337 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1338
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1339 return folder;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1340 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1341
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1342 static void
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1343 _handle_multiple_get_details_joinconf_cb(NMUser * user, NMERR_T ret_code,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1344 gpointer resp_data, gpointer user_data)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1345 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1346 NMRequest *request = user_data;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1347 NMUserRecord *user_record = resp_data;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1348 NMConference *conference;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1349 GSList *list, *node;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1350
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1351 if (user == NULL || resp_data == NULL || user_data == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1352 return;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1353
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1354 conference = nm_request_get_data(request);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1355 list = nm_request_get_user_define(request);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1356
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1357 if (ret_code == 0 && conference && list) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1358
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1359 /* Add the user to the conference */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1360 nm_conference_add_participant(conference, user_record);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1361
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1362 /* Find the user in the list and remove it */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1363 for (node = list; node; node = node->next) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1364 if (nm_utf8_str_equal(nm_user_record_get_dn(user_record),
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1365 (const char *) node->data)) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1366 list = g_slist_remove(list, node->data);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1367 nm_request_set_user_define(request, list);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1368 g_free(node->data);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1369 break;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1370 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1371 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1372
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1373 /* Time to callback? */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1374 if (g_slist_length(list) == 0) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1375 nm_response_cb cb = nm_request_get_callback(request);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1376
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1377 if (cb) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1378 cb(user, 0, conference, conference);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1379 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1380 g_slist_free(list);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1381 nm_release_request(request);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1382 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1383 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1384 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1385
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1386 NMERR_T
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1387 nm_call_handler(NMUser * user, NMRequest * request, NMField * fields)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1388 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1389 NMERR_T rc = NM_OK, ret_code = NM_OK;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1390 NMConference *conf = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1391 NMUserRecord *user_record = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1392 NMField *locate = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1393 NMField *field = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1394 const char *cmd;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1395 nm_response_cb cb;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1396 gboolean done = TRUE;
8684
046dd8ef2920 [gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents: 8675
diff changeset
1397
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1398 if (user == NULL || request == NULL || fields == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1399 return NMERR_BAD_PARM;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1400
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1401 /* Get the return code */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1402 field = nm_locate_field(NM_A_SZ_RESULT_CODE, fields);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1403 if (field) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1404 ret_code = atoi((char *) field->value);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1405 } else {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1406 ret_code = NMERR_PROTOCOL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1407 }
8684
046dd8ef2920 [gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents: 8675
diff changeset
1408
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1409 cmd = nm_request_get_cmd(request);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1410 if (ret_code == NM_OK && cmd != NULL) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1411
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1412 if (strcmp("login", cmd) == 0) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1413
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1414 user->user_record = nm_create_user_record_from_fields(fields);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1415
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1416 /* Save the users fields */
8744
0f73e8204529 [gaim-migrate @ 9499]
Luke Schierer <lschiere@pidgin.im>
parents: 8684
diff changeset
1417 user->fields = nm_copy_field_array(fields);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1418
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1419 } else if (strcmp("setstatus", cmd) == 0) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1420
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1421 /* Nothing to do */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1422
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1423 } else if (strcmp("createconf", cmd) == 0) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1424
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1425 conf = (NMConference *) nm_request_get_data(request);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1426
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1427 /* get the convo guid */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1428 locate = nm_locate_field(NM_A_FA_CONVERSATION, fields);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1429 if (locate) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1430 field =
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1431 nm_locate_field(NM_A_SZ_OBJECT_ID, (NMField *) fields->value);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1432 if (field) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1433 nm_conference_set_guid(conf, (char *) field->value);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1434 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1435 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1436
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1437 nm_conference_list_add(user, conf);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1438
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1439 } else if (strcmp("leaveconf", cmd) == 0) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1440
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1441 conf = (NMConference *) nm_request_get_data(request);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1442 nm_conference_list_remove(user, conf);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1443
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1444 } else if (strcmp("joinconf", cmd) == 0) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1445 GSList *list = NULL, *node;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1446
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1447 conf = nm_request_get_data(request);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1448
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1449 locate = nm_locate_field(NM_A_FA_CONTACT_LIST, fields);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1450 if (locate && locate->value != 0) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1451
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1452 field = (NMField *) locate->value;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1453 while ((field = nm_locate_field(NM_A_SZ_DN, field))) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1454 if (field && field->value != 0) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1455
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1456 if (nm_utf8_str_equal
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1457 (nm_user_record_get_dn(user->user_record),
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1458 (const char *) field->value)) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1459 field++;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1460 continue;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1461 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1462
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1463 user_record =
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1464 nm_find_user_record(user,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1465 (const char *) field->value);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1466 if (user_record == NULL) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1467 list =
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1468 g_slist_append(list,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1469 g_strdup((char *) field->value));
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1470 } else {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1471 nm_conference_add_participant(conf, user_record);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1472 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1473 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1474 field++;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1475 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1476
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1477 if (list != NULL) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1478
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1479 done = FALSE;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1480 nm_request_add_ref(request);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1481 nm_request_set_user_define(request, list);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1482 for (node = list; node; node = node->next) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1483
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1484 nm_send_get_details(user, (const char *) node->data,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1485 _handle_multiple_get_details_joinconf_cb,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1486 request);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1487 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1488 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1489 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1490
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1491 } else if (strcmp("getdetails", cmd) == 0) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1492
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1493 locate = nm_locate_field(NM_A_FA_RESULTS, fields);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1494 if (locate && locate->value != 0) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1495
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1496 user_record = nm_create_user_record_from_fields(locate);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1497 if (user_record) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1498 NMUserRecord *tmp;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1499
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1500 tmp =
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1501 nm_find_user_record(user,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1502 nm_user_record_get_dn(user_record));
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1503 if (tmp) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1504
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1505 /* Update the existing user record */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1506 nm_user_record_copy(tmp, user_record);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1507 nm_release_user_record(user_record);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1508 user_record = tmp;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1509
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1510 } else {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1511
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1512 nm_user_add_user_record(user, user_record);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1513 nm_release_user_record(user_record);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1514
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1515 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1516
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1517 /* Response data is new user record */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1518 nm_request_set_data(request, (gpointer) user_record);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1519 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1520
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1521 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1522
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1523 } else if (strcmp("createfolder", cmd) == 0) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1524
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1525 _update_contact_list(user, fields);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1526
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1527 } else if (strcmp("createcontact", cmd) == 0) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1528
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1529 _update_contact_list(user, fields);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1530
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1531 locate =
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1532 nm_locate_field(NM_A_SZ_OBJECT_ID, (NMField *) fields->value);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1533 if (locate) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1534
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1535 NMContact *new_contact =
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1536 nm_folder_find_item_by_object_id(user->root_folder,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1537 atoi((char *) locate->
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1538 value));
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1539
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1540 if (new_contact) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1541
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1542 /* Add the contact to our cache */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1543 nm_user_add_contact(user, new_contact);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1544
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1545 /* Set the contact as the response data */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1546 nm_request_set_data(request, (gpointer) new_contact);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1547
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1548 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1549
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1550 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1551
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1552 } else if (strcmp("deletecontact", cmd) == 0) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1553
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1554 _update_contact_list(user, fields);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1555
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1556 } else if (strcmp("movecontact", cmd) == 0) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1557
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1558 _update_contact_list(user, fields);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1559
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1560 } else if (strcmp("getstatus", cmd) == 0) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1561
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1562 locate = nm_locate_field(NM_A_SZ_STATUS, fields);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1563 if (locate) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1564 nm_user_record_set_status((NMUserRecord *)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1565 nm_request_get_data(request),
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1566 atoi((char *) locate->value), NULL);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1567 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1568
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1569 } else if (strcmp("updateitem", cmd) == 0) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1570
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1571 /* Nothing extra to do here */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1572
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1573 } else {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1574
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1575 /* Nothing to do, just print debug message */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1576 gaim_debug(GAIM_DEBUG_INFO, "novell",
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1577 "nm_call_handler(): Unknown request command, %s\n", cmd);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1578
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1579 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1580 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1581
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1582 if (done && (cb = nm_request_get_callback(request))) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1583
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1584 cb(user, ret_code, nm_request_get_data(request),
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1585 nm_request_get_user_define(request));
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1586
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1587 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1588
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1589 return rc;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1590 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1591
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1592 static NMERR_T
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1593 nm_process_response(NMUser * user)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1594 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1595 NMERR_T rc = NM_OK;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1596 NMField *fields = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1597 NMField *field = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1598 NMConn *conn = user->conn;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1599 NMRequest *req = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1600
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1601 rc = nm_read_header(conn);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1602 if (rc == NM_OK) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1603 rc = nm_read_fields(conn, -1, &fields);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1604 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1605
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1606 if (rc == NM_OK) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1607 field = nm_locate_field(NM_A_SZ_TRANSACTION_ID, fields);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1608 if (field != NULL && field->value != 0) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1609 req = nm_conn_find_request(conn, atoi((char *) field->value));
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1610 if (req != NULL) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1611 rc = nm_call_handler(user, req, fields);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1612 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1613 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1614 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1615
8744
0f73e8204529 [gaim-migrate @ 9499]
Luke Schierer <lschiere@pidgin.im>
parents: 8684
diff changeset
1616 if (fields)
0f73e8204529 [gaim-migrate @ 9499]
Luke Schierer <lschiere@pidgin.im>
parents: 8684
diff changeset
1617 nm_free_fields(&fields);
0f73e8204529 [gaim-migrate @ 9499]
Luke Schierer <lschiere@pidgin.im>
parents: 8684
diff changeset
1618
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1619 return rc;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1620 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1621
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1622 /*
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1623 * Some utility functions...haven't figured out where
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1624 * they belong yet.
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1625 */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1626 gint
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1627 nm_utf8_strcasecmp(gconstpointer str1, gconstpointer str2)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1628 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1629 gint rv;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1630 char *str1_down = g_utf8_strdown(str1, -1);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1631 char *str2_down = g_utf8_strdown(str2, -1);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1632
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1633 rv = g_utf8_collate(str1_down, str2_down);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1634
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1635 g_free(str1_down);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1636 g_free(str2_down);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1637
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1638 return rv;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1639 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1640
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1641 gboolean
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1642 nm_utf8_str_equal(gconstpointer str1, gconstpointer str2)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1643 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1644 return (nm_utf8_strcasecmp(str1, str2) == 0);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1645 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1646
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1647 char *
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1648 nm_typed_to_dotted(const char *typed)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1649 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1650 unsigned i = 0, j = 0;
8782
5a2b5e4abf3a [gaim-migrate @ 9544]
Christian Hammond <chipx86@chipx86.com>
parents: 8744
diff changeset
1651 char *dotted;
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1652
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1653 if (typed == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1654 return NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1655
8782
5a2b5e4abf3a [gaim-migrate @ 9544]
Christian Hammond <chipx86@chipx86.com>
parents: 8744
diff changeset
1656 dotted = g_new0(char, strlen(typed));
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1657
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1658 do {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1659
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1660 /* replace comma with a dot */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1661 if (j != 0) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1662 dotted[j] = '.';
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1663 j++;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1664 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1665
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1666 /* skip the type */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1667 while (typed[i] != '\0' && typed[i] != '=')
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1668 i++;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1669
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1670 /* verify that we aren't running off the end */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1671 if (typed[i] == '\0') {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1672 dotted[j] = '\0';
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1673 break;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1674 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1676 i++;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1677
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1678 /* copy the object name to context */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1679 while (typed[i] != '\0' && typed[i] != ',') {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1680 dotted[j] = typed[i];
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1681 j++;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1682 i++;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1683 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1684
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1685 } while (typed[i] != '\0');
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1686
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1687 return dotted;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1688 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1689
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1690 static void
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1691 _update_contact_list(NMUser * user, NMField * fields)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1692 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1693 NMField *list, *cursor, *locate;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1694 gint objid1;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1695 NMContact *contact;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1696 NMFolder *folder;
8782
5a2b5e4abf3a [gaim-migrate @ 9544]
Christian Hammond <chipx86@chipx86.com>
parents: 8744
diff changeset
1697 gpointer item;
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1698
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1699 if (user == NULL || fields == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1700 return;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1701
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1702 /* Is it wrapped in a RESULTS array? */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1703 if (strcmp(fields->tag, NM_A_FA_RESULTS) == 0) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1704 list = (NMField *) fields->value;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1705 } else {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1706 list = fields;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1707 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1708
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1709 /* Update the cached contact list */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1710 cursor = (NMField *) list->value;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1711 while (cursor->tag != NULL) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1712 if ((g_ascii_strcasecmp(cursor->tag, NM_A_FA_CONTACT) == 0) ||
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1713 (g_ascii_strcasecmp(cursor->tag, NM_A_FA_FOLDER) == 0)) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1714
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1715 locate =
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1716 nm_locate_field(NM_A_SZ_OBJECT_ID, (NMField *) cursor->value);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1717 if (locate != NULL && locate->value != 0) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1718 objid1 = atoi((char *) locate->value);
8782
5a2b5e4abf3a [gaim-migrate @ 9544]
Christian Hammond <chipx86@chipx86.com>
parents: 8744
diff changeset
1719 item =
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1720 nm_folder_find_item_by_object_id(user->root_folder, objid1);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1721 if (item != NULL) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1722 if (cursor->method == NMFIELD_METHOD_ADD) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1723 if (g_ascii_strcasecmp(cursor->tag, NM_A_FA_CONTACT) == 0) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1724 contact = (NMContact *) item;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1725 nm_contact_update_list_properties(contact, cursor);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1726 } else if (g_ascii_strcasecmp(cursor->tag, NM_A_FA_FOLDER)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1727 == 0) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1728 folder = (NMFolder *) item;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1729 nm_folder_update_list_properties(folder, cursor);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1730 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1731 } else if (cursor->method == NMFIELD_METHOD_DELETE) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1732 if (g_ascii_strcasecmp(cursor->tag, NM_A_FA_CONTACT) == 0) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1733 contact = (NMContact *) item;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1734 folder =
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1735 nm_find_folder_by_id(user,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1736 nm_contact_get_parent_id
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1737 (contact));
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1738 if (folder) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1739 nm_folder_remove_contact(folder, contact);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1740 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1741 } else if (g_ascii_strcasecmp(cursor->tag, NM_A_FA_FOLDER)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1742 == 0) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1743 /* TODO: write nm_folder_remove_folder */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1744 /* ignoring for now, should not be a big deal */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1745 /* folder = (NMFolder *) item;*/
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1746 /* nm_folder_remove_folder(user->root_folder, folder);*/
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1747 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1748 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1749 } else {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1750
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1751 if (cursor->method == NMFIELD_METHOD_ADD) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1752
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1753 /* Not found, so we need to add it */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1754 if (g_ascii_strcasecmp(cursor->tag, NM_A_FA_CONTACT) == 0) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1755
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1756 const char *dn = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1757
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1758 locate =
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1759 nm_locate_field(NM_A_SZ_DN,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1760 (NMField *) cursor->value);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1761 if (locate != NULL && locate->value != 0) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1762 dn = (const char *) locate->value;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1763 if (dn != NULL) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1764 contact =
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1765 nm_create_contact_from_fields(cursor);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1766 if (contact) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1767 nm_folder_add_contact_to_list(user->
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1768 root_folder,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1769 contact);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1770 nm_release_contact(contact);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1771 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1772 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1773 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1774 } else if (g_ascii_strcasecmp(cursor->tag, NM_A_FA_FOLDER)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1775 == 0) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1776 folder = nm_create_folder_from_fields(cursor);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1777 nm_folder_add_folder_to_list(user->root_folder,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1778 folder);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1779 nm_release_folder(folder);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1780 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1781 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1782 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1783 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1784 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1785 cursor++;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1786 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1787 }