annotate src/protocols/novell/nmuser.c @ 13579:ffb752f106ec

[gaim-migrate @ 15961] crash fix for invalid mime images committer: Tailor Script <tailor@pidgin.im>
author Christopher O'Brien <siege@pidgin.im>
date Tue, 04 Apr 2006 21:33:46 +0000
parents a88ca6da0b38
children
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 *
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
4 * Copyright (c) 2004 Novell, Inc. All Rights Reserved.
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
5 *
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
6 * This program is free software; you can redistribute it and/or modify
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
7 * it under the terms of the GNU General Public License as published by
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
8 * the Free Software Foundation; version 2 of the License.
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 *
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
10 * This program is distributed in the hope that it will be useful,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
13 * GNU General Public License for more details.
8684
046dd8ef2920 [gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents: 8675
diff changeset
14 *
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
15 * You should have received a copy of the GNU General Public License
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
16 * along with this program; if not, write to the Free Software
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 *
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 */
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 #include <glib.h>
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22 #include <string.h>
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
23 #include "internal.h"
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24 #include "nmfield.h"
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25 #include "nmuser.h"
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26 #include "nmconn.h"
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27 #include "nmcontact.h"
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 #include "nmuserrecord.h"
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 #include "util.h"
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30
8684
046dd8ef2920 [gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents: 8675
diff changeset
31 /* 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
32 * GW Messenger clients expect messages to be in RTF.
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 */
9268
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
34 #define RTF_TEMPLATE "{\\rtf1\\ansi\n"\
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
35 "{\\fonttbl{\\f0\\fnil Unknown;}}\n"\
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
36 "{\\colortbl ;\\red0\\green0\\blue0;}\n"\
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
37 "\\uc1\\cf1\\f0\\fs24 %s\\par\n}"
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
38 #define NM_MAX_MESSAGE_SIZE 2048
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40 static NMERR_T nm_process_response(NMUser * user);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41 static void _update_contact_list(NMUser * user, NMField * fields);
9268
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
42 static void _handle_multiple_get_details_login_cb(NMUser * user, NMERR_T ret_code,
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
43 gpointer resp_data, gpointer user_data);
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
44 static char * nm_rtfize_text(char *text);
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
45
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46 /**
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47 * See header for comments on on "public" functions
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
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50 NMUser *
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51 nm_initialize_user(const char *name, const char *server_addr,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52 int port, gpointer data, nm_event_cb event_callback)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53 {
8782
5a2b5e4abf3a [gaim-migrate @ 9544]
Christian Hammond <chipx86@chipx86.com>
parents: 8744
diff changeset
54 NMUser *user;
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55 if (name == NULL || server_addr == NULL || event_callback == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56 return NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57
8782
5a2b5e4abf3a [gaim-migrate @ 9544]
Christian Hammond <chipx86@chipx86.com>
parents: 8744
diff changeset
58 user = g_new0(NMUser, 1);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
60
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62 user->contacts =
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
63 g_hash_table_new_full(g_str_hash, nm_utf8_str_equal,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64 g_free, (GDestroyNotify) nm_release_contact);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66 user->user_records =
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67 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
68 (GDestroyNotify) nm_release_user_record);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70 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
71 g_free, g_free);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
72
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
73 user->name = g_strdup(name);
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
74 user->conn = nm_create_conn(server_addr, port);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
75 user->conn->addr = g_strdup(server_addr);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76 user->conn->port = port;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
77 user->evt_callback = event_callback;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78 user->client_data = data;
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 return user;
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
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84 void
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
85 nm_deinitialize_user(NMUser * user)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
86 {
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
87 nm_release_conn(user->conn);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
88
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89 if (user->contacts) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
90 g_hash_table_destroy(user->contacts);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
91 }
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 if (user->user_records) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
94 g_hash_table_destroy(user->user_records);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
95 }
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 if (user->display_id_to_dn) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
98 g_hash_table_destroy(user->display_id_to_dn);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
99 }
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 if (user->name) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
102 g_free(user->name);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
103 }
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 if (user->user_record) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
106 nm_release_user_record(user->user_record);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
107 }
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 nm_conference_list_free(user);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110 nm_destroy_contact_list(user);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
111
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
112 g_free(user);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113 }
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 NMERR_T
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116 nm_send_login(NMUser * user, const char *pwd, const char *my_addr,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
117 const char *user_agent, nm_response_cb callback, gpointer data)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
119 NMERR_T rc = NM_OK;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120 NMField *fields = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
121
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
122 if (user == NULL || pwd == NULL || user_agent == NULL) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
123 return NMERR_BAD_PARM;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
124 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
125
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
126 fields = nm_field_add_pointer(fields, NM_A_SZ_USERID, 0, NMFIELD_METHOD_VALID, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
127 g_strdup(user->name), NMFIELD_TYPE_UTF8);
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
128
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
129 fields = nm_field_add_pointer(fields, NM_A_SZ_CREDENTIALS, 0, NMFIELD_METHOD_VALID, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
130 g_strdup(pwd), NMFIELD_TYPE_UTF8);
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
131
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
132 fields = nm_field_add_pointer(fields, NM_A_SZ_USER_AGENT, 0, NMFIELD_METHOD_VALID, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
133 g_strdup(user_agent), NMFIELD_TYPE_UTF8);
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
134
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
135 fields = nm_field_add_number(fields, NM_A_UD_BUILD, 0, NMFIELD_METHOD_VALID, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
136 NM_PROTOCOL_VERSION, NMFIELD_TYPE_UDWORD);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137 if (my_addr) {
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
138 fields = nm_field_add_pointer(fields, NM_A_IP_ADDRESS, 0, NMFIELD_METHOD_VALID, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
139 g_strdup(my_addr), NMFIELD_TYPE_UTF8);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
140 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
141
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
142 /* Send the login */
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
143 rc = nm_send_request(user->conn, "login", fields, callback, data, NULL);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
144
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
145 nm_free_fields(&fields);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
146 return rc;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
147 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
148
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
149 NMERR_T
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
150 nm_send_set_status(NMUser * user, int status, const char *text,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
151 const char *auto_resp, nm_response_cb callback, gpointer data)
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 NMERR_T rc = NM_OK;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
154 NMField *fields = NULL;
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 if (user == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
157 return NMERR_BAD_PARM;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
158
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
159 /* Add the status */
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
160 fields = nm_field_add_pointer(fields, NM_A_SZ_STATUS, 0, NMFIELD_METHOD_VALID, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
161 g_strdup_printf("%d", status), NMFIELD_TYPE_UTF8);
8675
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 /* Add the status text and auto reply text if there is any */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
164 if (text) {
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
165 fields = nm_field_add_pointer(fields, NM_A_SZ_STATUS_TEXT, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
166 NMFIELD_METHOD_VALID, 0, g_strdup(text),
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
167 NMFIELD_TYPE_UTF8);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
168 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
169
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
170 if (auto_resp) {
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
171 fields = nm_field_add_pointer(fields, NM_A_SZ_MESSAGE_BODY, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
172 NMFIELD_METHOD_VALID, 0, g_strdup(auto_resp),
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
173 NMFIELD_TYPE_UTF8);
8675
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
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
176 rc = nm_send_request(user->conn, "setstatus", fields, callback, data, NULL);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
177
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
178 nm_free_fields(&fields);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
179 return rc;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
181
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182 NMERR_T
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
183 nm_send_multiple_get_details(NMUser * user, GSList *names,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
184 nm_response_cb callback, gpointer data)
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
185 {
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
186 NMERR_T rc = NM_OK;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
187 NMField *fields = NULL;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
188 GSList *node;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
189
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
190 if (user == NULL || names == NULL)
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
191 return NMERR_BAD_PARM;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
192
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
193 /* Add in DN or display id */
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
194 for (node = names; node; node = node->next) {
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
195 fields = nm_field_add_pointer(fields, NM_A_SZ_USERID, 0, NMFIELD_METHOD_VALID, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
196 g_strdup(node->data), NMFIELD_TYPE_UTF8);
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
197 }
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
198
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
199 rc = nm_send_request(user->conn, "getdetails", fields, callback, data, NULL);
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
200
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
201 nm_free_fields(&fields);
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
202 return rc;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
203 }
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
204
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
205 NMERR_T
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
206 nm_send_get_details(NMUser * user, const char *name,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
207 nm_response_cb callback, gpointer data)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
208 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
209 NMERR_T rc = NM_OK;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
210 NMField *fields = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
211
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
212 if (user == NULL || name == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
213 return NMERR_BAD_PARM;
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 /* Add in DN or display id */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
216 if (strstr("=", name)) {
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
217 fields = nm_field_add_pointer(fields, NM_A_SZ_DN, 0, NMFIELD_METHOD_VALID, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
218 g_strdup(name), NMFIELD_TYPE_DN);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
219 } else {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
220
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
221 const char *dn = nm_lookup_dn(user, name);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
222 if (dn) {
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
223 fields = nm_field_add_pointer(fields, NM_A_SZ_DN, 0, NMFIELD_METHOD_VALID, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
224 g_strdup(name), NMFIELD_TYPE_DN);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
225 } else {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
226 fields =
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
227 nm_field_add_pointer(fields, NM_A_SZ_USERID, 0, NMFIELD_METHOD_VALID, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
228 g_strdup(name), NMFIELD_TYPE_UTF8);
8675
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
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
231 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
232
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
233 rc = nm_send_request(user->conn, "getdetails", fields, callback, data, NULL);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
234
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
235 nm_free_fields(&fields);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
236 return rc;
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 NMERR_T
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
240 nm_send_create_conference(NMUser * user, NMConference * conference,
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
241 nm_response_cb callback, gpointer data)
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
242 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
243 NMERR_T rc = NM_OK;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
244 NMField *fields = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
245 NMField *tmp = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
246 NMField *field = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
247 NMRequest *req = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
248 int count, i;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
249
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
250 if (user == NULL || conference == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
251 return NMERR_BAD_PARM;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
252
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
253 /* Add in a blank guid */
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
254 tmp = nm_field_add_pointer(tmp, NM_A_SZ_OBJECT_ID, 0, NMFIELD_METHOD_VALID, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
255 g_strdup(BLANK_GUID), NMFIELD_TYPE_UTF8);
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
256
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
257 fields = nm_field_add_pointer(fields, NM_A_FA_CONVERSATION, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
258 NMFIELD_METHOD_VALID, 0, tmp,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
259 NMFIELD_TYPE_ARRAY);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
260 tmp = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
261
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
262
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
263 /* Add participants in */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
264 count = nm_conference_get_participant_count(conference);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
265 for (i = 0; i < count; i++) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
266 NMUserRecord *user_record = nm_conference_get_participant(conference, 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_record) {
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
269 fields = nm_field_add_pointer(fields, NM_A_SZ_DN,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
270 0, NMFIELD_METHOD_VALID, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
271 g_strdup(nm_user_record_get_dn(user_record)),
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
272 NMFIELD_TYPE_DN);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
273 }
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
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
276 /* Add our user in */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
277 field = nm_locate_field(NM_A_SZ_DN, user->fields);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
278 if (field) {
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
279 fields = nm_field_add_pointer(fields, NM_A_SZ_DN,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
280 0, NMFIELD_METHOD_VALID, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
281 g_strdup((char *) field->ptr_value),
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
282 NMFIELD_TYPE_DN);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
283 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
284
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
285 rc = nm_send_request(user->conn, "createconf", fields, callback, data, &req);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
286 if (rc == NM_OK && req) {
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
287 nm_conference_add_ref(conference);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
288 nm_request_set_data(req, conference);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
289 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
290
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
291 if (req)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
292 nm_release_request(req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
293
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
294 nm_free_fields(&fields);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
295 return rc;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
296 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
297
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
298 NMERR_T
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
299 nm_send_leave_conference(NMUser * user, NMConference * conference,
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
300 nm_response_cb callback, gpointer data)
8675
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 NMERR_T rc = NM_OK;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
303 NMField *fields = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
304 NMField *tmp = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
305 NMRequest *req = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
306
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
307 if (user == NULL || conference == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
308 return NMERR_BAD_PARM;
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 /* Add in the conference guid */
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
311 tmp = nm_field_add_pointer(tmp, NM_A_SZ_OBJECT_ID, 0, NMFIELD_METHOD_VALID, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
312 g_strdup(nm_conference_get_guid(conference)),
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
313 NMFIELD_TYPE_UTF8);
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
314
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
315 fields = nm_field_add_pointer(fields, NM_A_FA_CONVERSATION, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
316 NMFIELD_METHOD_VALID, 0, tmp,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
317 NMFIELD_TYPE_ARRAY);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
318 tmp = NULL;
8684
046dd8ef2920 [gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents: 8675
diff changeset
319
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
320 /* Send the request to the server */
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
321 rc = nm_send_request(user->conn, "leaveconf", fields, callback, data, &req);
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
322 if (rc == NM_OK && req)
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
323 nm_request_set_data(req, conference);
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 if (req)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
326 nm_release_request(req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
327
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
328 nm_free_fields(&fields);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
329 return rc;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
330 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
331
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
332 NMERR_T
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
333 nm_send_join_conference(NMUser * user, NMConference * conference,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
334 nm_response_cb callback, gpointer data)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
335 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
336 NMERR_T rc = NM_OK;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
337 NMField *fields = NULL, *tmp = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
338 NMRequest *req = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
339
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
340 if (user == NULL || conference == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
341 return NMERR_BAD_PARM;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
342
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
343 /* Add in the conference guid */
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
344 tmp = nm_field_add_pointer(tmp, NM_A_SZ_OBJECT_ID, 0, NMFIELD_METHOD_VALID, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
345 g_strdup(nm_conference_get_guid(conference)),
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
346 NMFIELD_TYPE_UTF8);
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
347
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
348 fields = nm_field_add_pointer(fields, NM_A_FA_CONVERSATION, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
349 NMFIELD_METHOD_VALID, 0, tmp,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
350 NMFIELD_TYPE_ARRAY);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
351 tmp = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
352
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
353 /* Send the request to the server */
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
354 rc = nm_send_request(user->conn, "joinconf", fields, callback, data, &req);
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
355 if (rc == NM_OK && req)
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
356 nm_request_set_data(req, conference);
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 if (req)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
359 nm_release_request(req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
360
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
361 nm_free_fields(&fields);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
362 return rc;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
363 }
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
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
366 nm_send_reject_conference(NMUser * user, NMConference * conference,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
367 nm_response_cb callback, gpointer data)
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 NMERR_T rc = NM_OK;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
370 NMField *fields = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
371 NMField *tmp = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
372 NMRequest *req = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
373
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
374 if (user == NULL || conference == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
375 return NMERR_BAD_PARM;
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 /* Add in the conference guid */
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
378 tmp = nm_field_add_pointer(tmp, NM_A_SZ_OBJECT_ID, 0, NMFIELD_METHOD_VALID, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
379 g_strdup(nm_conference_get_guid(conference)),
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
380 NMFIELD_TYPE_UTF8);
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
381
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
382 fields = nm_field_add_pointer(fields, NM_A_FA_CONVERSATION, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
383 NMFIELD_METHOD_VALID, 0, tmp,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
384 NMFIELD_TYPE_ARRAY);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
385 tmp = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
386
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
387 /* Send the request to the server */
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
388 rc = nm_send_request(user->conn, "rejectconf", fields, callback, data, &req);
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
389 if (rc == NM_OK && req)
8675
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
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
392 if (req)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
393 nm_release_request(req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
394
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
395 nm_free_fields(&fields);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
396 return rc;
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
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
399 NMERR_T
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
400 nm_send_conference_invite(NMUser *user, NMConference *conference, NMUserRecord *user_record,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
401 const char *message, nm_response_cb callback, gpointer data)
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
402 {
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
403 NMERR_T rc = NM_OK;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
404 NMField *fields = NULL;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
405 NMField *tmp = NULL;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
406 NMRequest *req = NULL;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
407
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
408 if (user == NULL || conference == NULL || user_record == NULL)
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
409 return NMERR_BAD_PARM;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
410
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
411 /* Add in the conference guid */
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
412 tmp = nm_field_add_pointer(tmp, NM_A_SZ_OBJECT_ID, 0, NMFIELD_METHOD_VALID, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
413 g_strdup(nm_conference_get_guid(conference)),
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
414 NMFIELD_TYPE_UTF8);
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
415
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
416 fields = nm_field_add_pointer(fields, NM_A_FA_CONVERSATION, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
417 NMFIELD_METHOD_VALID, 0, tmp,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
418 NMFIELD_TYPE_ARRAY);
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
419 tmp = NULL;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
420
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
421 /* Add in DN of user to invite */
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
422 fields = nm_field_add_pointer(fields, NM_A_SZ_DN, 0, NMFIELD_METHOD_VALID, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
423 g_strdup(nm_user_record_get_dn(user_record)),
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
424 NMFIELD_TYPE_DN);
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
425
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
426 /* Add the invite message if there is one */
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
427 if (message)
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
428 fields = nm_field_add_pointer(fields, NM_A_SZ_MESSAGE_BODY, 0, NMFIELD_METHOD_VALID, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
429 g_strdup(message), NMFIELD_TYPE_UTF8);
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
430
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
431 /* Send the request to the server */
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
432 rc = nm_send_request(user->conn, "sendinvite", fields, callback, data, &req);
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
433 if (rc == NM_OK && req)
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
434 nm_request_set_data(req, conference);
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
435
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
436 if (req)
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
437 nm_release_request(req);
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
438
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
439 nm_free_fields(&fields);
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
440 return rc;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
441 }
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
442
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
443 NMERR_T
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
444 nm_send_message(NMUser * user, NMMessage * message, nm_response_cb callback)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
445 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
446 NMERR_T rc = NM_OK;
9268
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
447 char *text, *rtfized;
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
448 NMField *fields = NULL, *tmp = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
449 NMConference *conf;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
450 NMUserRecord *user_record;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
451 int count, i;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
452
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
453 if (user == NULL || message == NULL) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
454 return NMERR_BAD_PARM;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
455 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
456
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
457 conf = nm_message_get_conference(message);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
458 if (!nm_conference_is_instantiated(conf)) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
459 rc = NMERR_CONFERENCE_NOT_INSTANTIATED;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
460 } else {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
461
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
462 tmp = nm_field_add_pointer(tmp, NM_A_SZ_OBJECT_ID, 0, NMFIELD_METHOD_VALID, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
463 g_strdup(nm_conference_get_guid(conf)),
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
464 NMFIELD_TYPE_UTF8);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
465
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
466 fields =
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
467 nm_field_add_pointer(fields, NM_A_FA_CONVERSATION, 0, NMFIELD_METHOD_VALID, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
468 tmp, NMFIELD_TYPE_ARRAY);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
469 tmp = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
470
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
471 /* Add RTF and plain text versions of the message */
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
472 text = g_strdup(nm_message_get_text(message));
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
473
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
474 /* Truncate if necessary */
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
475 if (strlen(text) > NM_MAX_MESSAGE_SIZE)
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
476 text[NM_MAX_MESSAGE_SIZE] = 0;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
477
9268
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
478 rtfized = nm_rtfize_text(text);
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
479
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
480 gaim_debug_info("novell", "message text is: %s\n", text);
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
481 gaim_debug_info("novell", "message rtf is: %s\n", rtfized);
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
482
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
483 tmp = nm_field_add_pointer(tmp, NM_A_SZ_MESSAGE_BODY, 0, NMFIELD_METHOD_VALID, 0,
9268
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
484 rtfized, NMFIELD_TYPE_UTF8);
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
485
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
486 tmp = nm_field_add_number(tmp, NM_A_UD_MESSAGE_TYPE, 0, NMFIELD_METHOD_VALID, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
487 0, NMFIELD_TYPE_UDWORD);
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
488
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
489 tmp = nm_field_add_pointer(tmp, NM_A_SZ_MESSAGE_TEXT, 0, NMFIELD_METHOD_VALID, 0,
9268
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
490 text, NMFIELD_TYPE_UTF8);
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
491
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
492 fields = nm_field_add_pointer(fields, NM_A_FA_MESSAGE, 0, NMFIELD_METHOD_VALID, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
493 tmp, NMFIELD_TYPE_ARRAY);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
494 tmp = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
495
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
496 /* Add participants */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
497 count = nm_conference_get_participant_count(conf);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
498 for (i = 0; i < count; i++) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
499 user_record = nm_conference_get_participant(conf, i);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
500 if (user_record) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
501 fields =
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
502 nm_field_add_pointer(fields, NM_A_SZ_DN, 0, NMFIELD_METHOD_VALID, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
503 g_strdup(nm_user_record_get_dn(user_record)),
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
504 NMFIELD_TYPE_DN);
8675
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
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
508 /* Send the request */
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
509 rc = nm_send_request(user->conn, "sendmessage", fields, callback, NULL, NULL);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
510 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
511
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
512 nm_free_fields(&fields);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
513 return rc;
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
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
516 NMERR_T
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
517 nm_send_typing(NMUser * user, NMConference * conf,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
518 gboolean typing, nm_response_cb callback)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
519 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
520 NMERR_T rc = NM_OK;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
521 char *str = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
522 NMField *fields = NULL, *tmp = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
523
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
524 if (user == NULL || conf == NULL) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
525 return NMERR_BAD_PARM;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
526 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
527
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
528 if (!nm_conference_is_instantiated(conf)) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
529 rc = NMERR_CONFERENCE_NOT_INSTANTIATED;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
530 } else {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
531 /* Add the conference GUID */
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
532 tmp = nm_field_add_pointer(tmp, NM_A_SZ_OBJECT_ID, 0, NMFIELD_METHOD_VALID, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
533 g_strdup(nm_conference_get_guid(conf)),
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
534 NMFIELD_TYPE_UTF8);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
535
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
536 /* Add typing type */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
537 str = g_strdup_printf("%d",
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
538 (typing ? NMEVT_USER_TYPING :
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
539 NMEVT_USER_NOT_TYPING));
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
540
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
541 tmp = nm_field_add_pointer(tmp, NM_A_SZ_TYPE, 0, NMFIELD_METHOD_VALID, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
542 str, NMFIELD_TYPE_UTF8);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
543
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
544 fields =
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
545 nm_field_add_pointer(fields, NM_A_FA_CONVERSATION, 0, NMFIELD_METHOD_VALID, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
546 tmp, NMFIELD_TYPE_ARRAY);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
547 tmp = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
548
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
549 rc = nm_send_request(user->conn, "sendtyping", fields, callback, NULL, NULL);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
550 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
551
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
552 nm_free_fields(&fields);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
553 return rc;
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
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
556 NMERR_T
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
557 nm_send_create_contact(NMUser * user, NMFolder * folder,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
558 NMContact * contact, nm_response_cb callback,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
559 gpointer data)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
560 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
561 NMERR_T rc = NM_OK;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
562 NMField *fields = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
563 NMRequest *req = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
564 const char *name = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
565 const char *display_name = NULL;
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 (user == NULL || folder == NULL || contact == NULL) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
568 return NMERR_BAD_PARM;
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
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
571 /* Add parent ID */
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
572 fields = nm_field_add_pointer(fields, NM_A_SZ_PARENT_ID, 0, NMFIELD_METHOD_VALID, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
573 g_strdup_printf("%d", nm_folder_get_id(folder)),
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
574 NMFIELD_TYPE_UTF8);
8675
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 /* Check to see if userid is current user and return an error? */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
577
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
578 /* Check to see if contact already exists and return an error? */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
579
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
580 /* Add userid or dn */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
581 name = nm_contact_get_dn(contact);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
582 if (name == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
583 return NMERR_BAD_PARM;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
584
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
585 if (strstr("=", name)) {
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
586 fields = nm_field_add_pointer(fields, NM_A_SZ_DN, 0, NMFIELD_METHOD_VALID, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
587 g_strdup(name), NMFIELD_TYPE_DN);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
588 } else {
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
589 fields = nm_field_add_pointer(fields, NM_A_SZ_USERID, 0, NMFIELD_METHOD_VALID, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
590 g_strdup(name), NMFIELD_TYPE_UTF8);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
591 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
592
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
593 /* Add display name */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
594 display_name = nm_contact_get_display_name(contact);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
595 if (display_name)
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
596 fields = nm_field_add_pointer(fields, NM_A_SZ_DISPLAY_NAME, 0, NMFIELD_METHOD_VALID, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
597 g_strdup(display_name), NMFIELD_TYPE_UTF8);
8684
046dd8ef2920 [gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents: 8675
diff changeset
598
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
599 /* Dispatch the request */
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
600 rc = nm_send_request(user->conn, "createcontact", fields, callback, data, &req);
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
601 if (rc == NM_OK && req)
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
602 nm_request_set_data(req, contact);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
603
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
604 if (req)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
605 nm_release_request(req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
606
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
607 nm_free_fields(&fields);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
608 return rc;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
609 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
610
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
611 NMERR_T
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
612 nm_send_remove_contact(NMUser * user, NMFolder * folder,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
613 NMContact * contact, nm_response_cb callback,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
614 gpointer data)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
615 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
616 NMERR_T rc = NM_OK;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
617 NMField *fields = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
618 NMRequest *req = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
619
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
620 if (user == NULL || folder == NULL || contact == NULL) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
621 return NMERR_BAD_PARM;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
622 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
623
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
624 /* Add parent id */
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
625 fields = nm_field_add_pointer(fields, NM_A_SZ_PARENT_ID, 0, NMFIELD_METHOD_VALID, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
626 g_strdup_printf("%d", nm_folder_get_id(folder)),
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
627 NMFIELD_TYPE_UTF8);
8675
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 /* Add object id */
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
630 fields = nm_field_add_pointer(fields, NM_A_SZ_OBJECT_ID, 0, NMFIELD_METHOD_VALID, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
631 g_strdup_printf("%d", nm_contact_get_id(contact)),
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
632 NMFIELD_TYPE_UTF8);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
633
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
634 /* Dispatch the request */
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
635 rc = nm_send_request(user->conn, "deletecontact", fields, callback, data, &req);
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
636 if (rc == NM_OK && req)
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
637 nm_request_set_data(req, contact);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
638
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
639 if (req)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
640 nm_release_request(req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
641
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
642 nm_free_fields(&fields);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
643 return rc;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
644 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
645
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
646 NMERR_T
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
647 nm_send_create_folder(NMUser * user, const char *name,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
648 nm_response_cb callback, gpointer data)
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 NMERR_T rc = NM_OK;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
651 NMField *fields = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
652 NMRequest *req = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
653
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
654 if (user == NULL || name == NULL) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
655 return NMERR_BAD_PARM;
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
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
658 /* Add parent ID */
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
659 fields = nm_field_add_pointer(fields, NM_A_SZ_PARENT_ID, 0, NMFIELD_METHOD_VALID, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
660 g_strdup("0"), NMFIELD_TYPE_UTF8);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
661
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
662 /* Add name of the folder to add */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
663 fields =
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
664 nm_field_add_pointer(fields, NM_A_SZ_DISPLAY_NAME, 0, NMFIELD_METHOD_VALID, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
665 g_strdup(name), NMFIELD_TYPE_UTF8);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
666
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
667 /* Add sequence, for now just put it at the bottom */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
668 fields =
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
669 nm_field_add_pointer(fields, NM_A_SZ_SEQUENCE_NUMBER, 0, NMFIELD_METHOD_VALID, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
670 g_strdup("-1"), NMFIELD_TYPE_UTF8);
8675
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 /* Dispatch the request */
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
673 rc = nm_send_request(user->conn, "createfolder", fields, callback, data, &req);
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
674 if (rc == NM_OK && req)
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
675 nm_request_set_data(req, g_strdup(name));
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
676
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
677 if (req)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
678 nm_release_request(req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
679
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
680 nm_free_fields(&fields);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
681 return rc;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
682 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
683
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
684 NMERR_T
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
685 nm_send_remove_folder(NMUser * user, NMFolder * folder,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
686 nm_response_cb callback, gpointer data)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
687 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
688 NMERR_T rc = NM_OK;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
689 NMField *fields = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
690 NMRequest *req = NULL;
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 if (user == NULL || folder == NULL) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
693 return NMERR_BAD_PARM;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
694 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
695
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
696 /* Add the object id */
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
697 fields = nm_field_add_pointer(fields, NM_A_SZ_OBJECT_ID, 0, NMFIELD_METHOD_VALID, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
698 g_strdup_printf("%d", nm_folder_get_id(folder)),
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
699 NMFIELD_TYPE_UTF8);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
700
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
701 /* Dispatch the request */
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
702 rc = nm_send_request(user->conn, "deletecontact", fields, callback, data, &req);
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
703 if (rc == NM_OK && req)
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
704 nm_request_set_data(req, folder);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
705
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
706 if (req)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
707 nm_release_request(req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
708
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
709 nm_free_fields(&fields);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
710 return rc;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
711 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
712
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
713 NMERR_T
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
714 nm_send_get_status(NMUser * user, NMUserRecord * user_record,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
715 nm_response_cb callback, gpointer data)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
716 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
717 NMERR_T rc = NM_OK;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
718 NMField *fields = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
719 NMRequest *req = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
720 const char *dn;
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 if (user == NULL || user_record == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
723 return NMERR_BAD_PARM;
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 /* Add DN to field list */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
726 dn = nm_user_record_get_dn(user_record);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
727 if (dn == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
728 return (NMERR_T) -1;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
729
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
730 fields = nm_field_add_pointer(fields, NM_A_SZ_DN, 0, NMFIELD_METHOD_VALID, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
731 g_strdup(dn), NMFIELD_TYPE_UTF8);
8675
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 /* Dispatch the request */
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
734 rc = nm_send_request(user->conn, "getstatus", fields, callback, data, &req);
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
735 if (rc == NM_OK && req)
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
736 nm_request_set_data(req, user_record);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
737
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
738 if (req)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
739 nm_release_request(req);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
740
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
741 nm_free_fields(&fields);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
742 return rc;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
743 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
744
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
745 NMERR_T
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
746 nm_send_rename_contact(NMUser * user, NMContact * contact,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
747 const char *new_name, nm_response_cb callback,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
748 gpointer data)
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 NMERR_T rc = NM_OK;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
751 NMField *field = NULL, *fields = NULL, *list = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
752 NMRequest *req = NULL;
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 (user == NULL || contact == NULL || new_name == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
755 return NMERR_BAD_PARM;
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 /* Create field list for current contact */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
758 field = nm_contact_to_fields(contact);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
759 if (field) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
760
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
761 fields =
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
762 nm_field_add_pointer(fields, NM_A_FA_CONTACT, 0, NMFIELD_METHOD_DELETE, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
763 field, NMFIELD_TYPE_ARRAY);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
764 field = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
765
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
766 /* Update the contacts display name locally */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
767 nm_contact_set_display_name(contact, new_name);
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 /* Create field list for updated contact */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
770 field = nm_contact_to_fields(contact);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
771 if (field) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
772 fields =
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
773 nm_field_add_pointer(fields, NM_A_FA_CONTACT, 0, NMFIELD_METHOD_ADD, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
774 field, NMFIELD_TYPE_ARRAY);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
775 field = NULL;
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 /* Package it up */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
778 list =
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
779 nm_field_add_pointer(list, NM_A_FA_CONTACT_LIST, 0, NMFIELD_METHOD_VALID,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
780 0, fields, NMFIELD_TYPE_ARRAY);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
781 fields = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
782
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
783 rc = nm_send_request(user->conn, "updateitem", list, callback, data, &req);
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
784 if (rc == NM_OK && req)
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
785 nm_request_set_data(req, contact);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
786 }
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
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
789 if (req)
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
790 nm_release_request(req);
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
791
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
792 if (list)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
793 nm_free_fields(&list);
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_folder(NMUser * user, NMFolder * folder, const char *new_name,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
800 nm_response_cb callback, gpointer data)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
801 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
802 NMERR_T rc = NM_OK;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
803 NMField *field = NULL, *fields = NULL, *list = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
804 NMRequest *req = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
805
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
806 if (user == NULL || folder == NULL || new_name == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
807 return NMERR_BAD_PARM;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
808
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
809 /* Make sure folder does not already exist!? */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
810 if (nm_find_folder(user, new_name))
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
811 return NMERR_FOLDER_EXISTS;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
812
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
813 /* Create field list for current folder */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
814 field = nm_folder_to_fields(folder);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
815 if (field) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
816
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
817 fields = nm_field_add_pointer(fields, NM_A_FA_FOLDER, 0, NMFIELD_METHOD_DELETE, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
818 field, NMFIELD_TYPE_ARRAY);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
819 field = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
820
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
821 /* Update the folders display name locally */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
822 nm_folder_set_name(folder, new_name);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
823
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
824 /* Create field list for updated folder */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
825 field = nm_folder_to_fields(folder);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
826 if (field) {
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
827 fields = nm_field_add_pointer(fields, NM_A_FA_FOLDER, 0, NMFIELD_METHOD_ADD, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
828 field, NMFIELD_TYPE_ARRAY);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
829 field = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
830
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
831 /* Package it up */
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
832 list = nm_field_add_pointer(list, NM_A_FA_CONTACT_LIST, 0, NMFIELD_METHOD_VALID,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
833 0, fields, NMFIELD_TYPE_ARRAY);
8675
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
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
836 rc = nm_send_request(user->conn, "updateitem", list, callback, data, &req);
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
837 if (rc == NM_OK && req)
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
838 nm_request_set_data(req, folder);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
839 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
840 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
841
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
842 if (req)
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
843 nm_release_request(req);
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
844
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
845 if (list)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
846 nm_free_fields(&list);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
847
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
848 return rc;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
849 }
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 NMERR_T
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
852 nm_send_move_contact(NMUser * user, NMContact * contact, NMFolder * folder,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
853 nm_response_cb callback, gpointer data)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
854 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
855 NMERR_T rc = NM_OK;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
856 NMField *field = NULL, *fields = NULL, *list = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
857 NMRequest *req = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
858
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
859 if (user == NULL || contact == NULL || folder == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
860 return NMERR_BAD_PARM;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
861
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
862 /* Create field list for the contact */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
863 field = nm_contact_to_fields(contact);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
864 if (field) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
865
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
866 fields = nm_field_add_pointer(fields, NM_A_FA_CONTACT, 0, NMFIELD_METHOD_DELETE, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
867 field, NMFIELD_TYPE_ARRAY);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
868 field = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
869
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
870 /* Wrap the contact up and add it to the request field list */
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
871 list = nm_field_add_pointer(list, NM_A_FA_CONTACT_LIST, 0, NMFIELD_METHOD_VALID, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
872 fields, NMFIELD_TYPE_ARRAY);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
873 fields = 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 /* Add sequence number */
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
876 list = nm_field_add_pointer(list, NM_A_SZ_SEQUENCE_NUMBER, 0, NMFIELD_METHOD_VALID,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
877 0, g_strdup("-1"), NMFIELD_TYPE_UTF8);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
878
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
879 /* Add parent ID */
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
880 list = nm_field_add_pointer(list, NM_A_SZ_PARENT_ID, 0, NMFIELD_METHOD_VALID, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
881 g_strdup_printf("%d", nm_folder_get_id(folder)),
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
882 NMFIELD_TYPE_UTF8);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
883
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
884 /* Dispatch the request */
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
885 rc = nm_send_request(user->conn, "movecontact", list, callback, data, &req);
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
886 if (rc == NM_OK && req)
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
887 nm_request_set_data(req, contact);
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
888
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
889 }
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
890
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
891 if (req)
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
892 nm_release_request(req);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
893
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
894 if (list)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
895 nm_free_fields(&list);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
896
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
897 return rc;
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 NMERR_T
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
902 nm_send_create_privacy_item(NMUser *user, const char *who, gboolean allow_list,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
903 nm_response_cb callback, gpointer data)
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
904 {
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
905 NMERR_T rc = NM_OK;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
906 NMField *fields = NULL;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
907 const char *tag;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
908
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
909 if (user == NULL || who == NULL)
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
910 return NMERR_BAD_PARM;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
911
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
912 if (allow_list)
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
913 tag = NM_A_SZ_BLOCKING_ALLOW_ITEM;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
914 else
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
915 tag = NM_A_SZ_BLOCKING_DENY_ITEM;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
916
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
917 fields = nm_field_add_pointer(fields, tag, 0, NMFIELD_METHOD_ADD, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
918 g_strdup(who), NMFIELD_TYPE_UTF8);
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
919
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
920 rc = nm_send_request(user->conn, "createblock", fields, callback, data, NULL);
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
921
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
922 nm_free_fields(&fields);
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
923 return rc;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
924 }
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
925
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
926 NMERR_T
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
927 nm_send_remove_privacy_item(NMUser *user, const char *dn, gboolean allow_list,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
928 nm_response_cb callback, gpointer data)
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
929 {
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
930 NMERR_T rc = NM_OK;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
931 NMField *fields = NULL;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
932 const char *tag;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
933 GSList **list_ptr, *node;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
934
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
935 if (user == NULL || dn == NULL)
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
936 return NMERR_BAD_PARM;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
937
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
938 if (allow_list) {
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
939 tag = NM_A_BLOCKING_ALLOW_LIST;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
940 list_ptr = &user->allow_list;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
941 } else {
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
942 tag = NM_A_BLOCKING_DENY_LIST;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
943 list_ptr = &user->deny_list;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
944 }
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
945
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
946 /* Remove item from the cached list */
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
947 if ((node = g_slist_find_custom(*list_ptr, dn, (GCompareFunc)nm_utf8_strcasecmp))) {
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
948 *list_ptr = g_slist_remove_link(*list_ptr, node);
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
949 g_slist_free_1(node);
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
950 }
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
951
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
952 fields = nm_field_add_pointer(fields, tag, 0, NMFIELD_METHOD_DELETE, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
953 g_strdup(dn), NMFIELD_TYPE_DN);
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
954
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
955 rc = nm_send_request(user->conn, "updateblocks", fields, callback, data, NULL);
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
956
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
957 nm_free_fields(&fields);
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
958 return rc;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
959
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
960 }
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
961
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
962 NMERR_T
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
963 nm_send_set_privacy_default(NMUser *user, gboolean default_deny,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
964 nm_response_cb callback, gpointer data)
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
965 {
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
966 NMERR_T rc = NM_OK;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
967 NMField *fields = NULL;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
968
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
969 if (user == NULL)
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
970 return NMERR_BAD_PARM;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
971
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
972 fields = nm_field_add_pointer(fields, NM_A_BLOCKING, 0, NMFIELD_METHOD_UPDATE, 0,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
973 (default_deny ? g_strdup("1") : g_strdup("0")),
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
974 NMFIELD_TYPE_UTF8);
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
975
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
976 rc = nm_send_request(user->conn, "updateblocks", fields, callback, data, NULL);
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
977
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
978 nm_free_fields(&fields);
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
979 return rc;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
980 }
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
981
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
982 NMERR_T
9268
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
983 nm_send_keepalive(NMUser *user, nm_response_cb callback, gpointer data)
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
984 {
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
985 NMERR_T rc = NM_OK;
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
986
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
987 if (user == NULL)
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
988 return NMERR_BAD_PARM;
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
989
9360
d77537e8bfe5 [gaim-migrate @ 10168]
Luke Schierer <lschiere@pidgin.im>
parents: 9268
diff changeset
990 rc = nm_send_request(user->conn, "ping", NULL, callback, data, NULL);
9268
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
991
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
992 return rc;
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
993 }
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
994
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
995 NMERR_T
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
996 nm_process_new_data(NMUser * user)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
997 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
998 NMConn *conn;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
999 NMERR_T rc = NM_OK;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1000 int ret;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1001 guint32 val;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1002
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1003 if (user == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1004 return NMERR_BAD_PARM;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1005
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1006 conn = user->conn;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1007
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1008 /* Check to see if this is an event or a response */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1009 ret = nm_tcp_read(conn, (char *) &val, sizeof(val));
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1010 if (ret == sizeof(val)) {
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 if (strncmp((char *) &val, "HTTP", strlen("HTTP")) == 0)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1013 rc = nm_process_response(user);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1014 else
8874
a2affcdf8e01 [gaim-migrate @ 9643]
Luke Schierer <lschiere@pidgin.im>
parents: 8782
diff changeset
1015 rc = nm_process_event(user, GUINT32_FROM_LE(val));
8675
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 } else {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1018 rc = NMERR_PROTOCOL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1019 }
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 return rc;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1022 }
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 NMConference *
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1025 nm_find_conversation(NMUser * user, const char *who)
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 NMConference *conference = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1028 NMConference *tmp;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1029 GSList *cnode;
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 && user->conferences) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1032 for (cnode = user->conferences; cnode; cnode = cnode->next) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1033 tmp = cnode->data;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1034 if (nm_conference_get_participant_count(tmp) == 1) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1035 NMUserRecord *ur = nm_conference_get_participant(tmp, 0);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1036
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1037 if (ur) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1038 if (nm_utf8_str_equal(nm_user_record_get_dn(ur), who)) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1039 conference = tmp;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1040 break;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1041 }
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 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1044 }
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
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1047 return conference;
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
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1050 void
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1051 nm_conference_list_add(NMUser * user, NMConference * conf)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1052 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1053 if (user == NULL || conf == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1054 return;
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 nm_conference_add_ref(conf);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1057 user->conferences = g_slist_append(user->conferences, conf);
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 void
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1061 nm_conference_list_remove(NMUser * user, NMConference * conf)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1062 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1063 if (user == NULL || conf == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1064 return;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1065
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1066 if (g_slist_find(user->conferences, conf)) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1067 user->conferences = g_slist_remove(user->conferences, conf);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1068 nm_release_conference(conf);
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 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1071
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1072 void
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1073 nm_conference_list_free(NMUser * user)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1074 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1075 GSList *cnode;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1076 NMConference *conference;
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 if (user == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1079 return;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1080
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1081 if (user->conferences) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1082 for (cnode = user->conferences; cnode; cnode = cnode->next) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1083 conference = cnode->data;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1084 cnode->data = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1085 nm_release_conference(conference);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1086 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1087
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1088 g_slist_free(user->conferences);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1089 user->conferences = NULL;
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
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1093 NMConference *
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1094 nm_conference_list_find(NMUser * user, const char *guid)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1095 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1096 GSList *cnode;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1097 NMConference *conference = NULL, *tmp;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1098
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1099 if (user == NULL || guid == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1100 return NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1101
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1102 if (user->conferences) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1103 for (cnode = user->conferences; cnode; cnode = cnode->next) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1104 tmp = cnode->data;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1105 if (nm_are_guids_equal(nm_conference_get_guid(tmp), guid)) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1106 conference = tmp;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1107 break;
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 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1110 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1111
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1112 return conference;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1113 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1114
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1115 gboolean
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1116 nm_are_guids_equal(const char *guid1, const char *guid2)
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 if (guid1 == NULL || guid2 == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1119 return FALSE;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1120
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1121 return (strncmp(guid1, guid2, CONF_GUID_END) == 0);
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
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1124 void
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1125 nm_user_add_contact(NMUser * user, NMContact * contact)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1126 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1127 if (user == NULL || contact == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1128 return;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1129
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1130 nm_contact_add_ref(contact);
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 g_hash_table_insert(user->contacts,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1133 g_utf8_strdown(nm_contact_get_dn(contact), -1), contact);
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
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1136 void
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1137 nm_user_add_user_record(NMUser * user, NMUserRecord * user_record)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1138 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1139 nm_user_record_add_ref(user_record);
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 g_hash_table_insert(user->user_records,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1142 g_utf8_strdown(nm_user_record_get_dn(user_record), -1),
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1143 user_record);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1144
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1145 g_hash_table_insert(user->display_id_to_dn,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1146 g_utf8_strdown(nm_user_record_get_display_id(user_record),
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1147 -1),
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1148 g_utf8_strdown(nm_user_record_get_dn(user_record), -1));
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1149
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
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1152 nm_event_cb
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1153 nm_user_get_event_callback(NMUser * user)
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 if (user == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1156 return NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1157
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1158 return user->evt_callback;
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 NMConn *
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1162 nm_user_get_conn(NMUser * user)
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 if (user == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1165 return NULL;
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 return user->conn;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1168 }
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 NMERR_T
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1171 nm_create_contact_list(NMUser * user)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1172 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1173 NMERR_T rc = NM_OK;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1174 NMField *locate = NULL;
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 if (user == NULL || user->fields == NULL) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1177 return NMERR_BAD_PARM;
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
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1180 /* Create the root folder */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1181 user->root_folder = nm_create_folder("");
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1182
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1183 /* Find the contact list in the login fields */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1184 locate = nm_locate_field(NM_A_FA_CONTACT_LIST, user->fields);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1185 if (locate != NULL) {
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 /* Add the folders and then the contacts */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1188 nm_folder_add_contacts_and_folders(user, user->root_folder,
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1189 (NMField *) (locate->ptr_value));
8675
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 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1192
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1193 return rc;
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
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1196 gboolean nm_user_is_privacy_locked(NMUser *user)
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1197 {
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1198 if (user) {
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1199 return user->privacy_locked;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1200 }
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1201
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1202 return FALSE;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1203 }
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1204
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1205 static gboolean
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1206 _create_privacy_list(NMUser * user, NMRequest *request)
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1207 {
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1208 NMField *locate = NULL;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1209 GSList *need_details = NULL;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1210
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1211 /* Are the privacy settings locked */
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1212 locate = nm_locate_field(NM_A_LOCKED_ATTR_LIST, user->fields);
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1213 if (locate && locate->ptr_value) {
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1214 if (locate->type == NMFIELD_TYPE_UTF8 &&
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1215 (nm_utf8_strcasecmp(locate->ptr_value, NM_A_BLOCKING) == 0)) {
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1216 user->privacy_locked = TRUE;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1217 } else if (locate->type == NMFIELD_TYPE_MV ||
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1218 locate->type == NMFIELD_TYPE_ARRAY) {
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1219 NMField *tmp = (NMField *)locate->ptr_value;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1220 while (tmp && tmp->tag) {
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1221 if (nm_utf8_strcasecmp(tmp->ptr_value, NM_A_BLOCKING) == 0) {
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1222 user->privacy_locked = TRUE;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1223 break;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1224 }
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1225 tmp++;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1226 }
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1227 }
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1228 }
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1229
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1230 /* Set default deny flag */
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1231 locate = nm_locate_field(NM_A_BLOCKING, user->fields);
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1232 if (locate && locate->ptr_value) {
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1233 user->default_deny = atoi((char *)locate->ptr_value);
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1234 }
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1235
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1236 /* Read internal blocking allow list */
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1237 locate = nm_locate_field(NM_A_BLOCKING_ALLOW_LIST, user->fields);
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1238 if (locate && locate->ptr_value) {
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1239
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1240 if (locate->type == NMFIELD_TYPE_MV) {
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1241 locate = (NMField *)locate->ptr_value;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1242 for (; locate->tag != NULL; locate++) {
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1243 if (locate->ptr_value) {
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1244
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1245 user->allow_list = g_slist_append(user->allow_list, (char *)locate->ptr_value);
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1246
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1247 if (nm_find_user_record(user, (char *)locate->ptr_value) == NULL)
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1248 need_details = g_slist_append(need_details, (char *)locate->ptr_value);
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1249
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1250 }
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1251 }
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1252 } else {
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1253
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1254 user->allow_list = g_slist_append(user->allow_list, (char *)locate->ptr_value);
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1255
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1256 if (nm_find_user_record(user, (char *)locate->ptr_value) == NULL)
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1257 need_details = g_slist_append(need_details, (char *)locate->ptr_value);
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1258
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1259 }
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1260 }
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1261
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1262 /* Read internal blocking deny list */
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1263 locate = nm_locate_field(NM_A_BLOCKING_DENY_LIST, user->fields);
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1264 if (locate && locate->ptr_value) {
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1265
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1266 if (locate->type == NMFIELD_TYPE_MV) {
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1267 locate = (NMField *)locate->ptr_value;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1268 for (; locate->tag != NULL; locate++) {
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1269 if (locate->ptr_value) {
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1270
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1271 user->deny_list = g_slist_append(user->deny_list, (char *)locate->ptr_value);
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1272
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1273 if (nm_find_user_record(user, (char *)locate->ptr_value) == NULL)
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1274 need_details = g_slist_append(need_details, (char *)locate->ptr_value);
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1275
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1276 }
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1277 }
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1278 } else {
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1279
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1280 user->deny_list = g_slist_append(user->deny_list, (char *)locate->ptr_value);
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1281
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1282 if (nm_find_user_record(user, (char *)locate->ptr_value) == NULL)
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1283 need_details = g_slist_append(need_details, (char *)locate->ptr_value);
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1284
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1285 }
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1286 }
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1287
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1288 if (need_details) {
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1289
9268
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
1290 nm_request_add_ref(request);
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1291 nm_send_multiple_get_details(user, need_details,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1292 _handle_multiple_get_details_login_cb, request);
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1293
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1294 return FALSE;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1295 }
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1296
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1297 return TRUE;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1298 }
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1299
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1300 void
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1301 nm_destroy_contact_list(NMUser * user)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1302 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1303 if (user == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1304 return;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1305
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1306 if (user->root_folder) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1307 nm_release_folder(user->root_folder);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1308 user->root_folder = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1309 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1310 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1311
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1312 NMFolder *
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1313 nm_get_root_folder(NMUser * user)
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 if (user == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1316 return NULL;
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 if (user->root_folder == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1319 nm_create_contact_list(user);
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 return user->root_folder;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1322 }
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 NMContact *
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1325 nm_find_contact(NMUser * user, const char *name)
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 char *str;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1328 const char *dn = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1329 NMContact *contact = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1330
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1331 if (user == NULL || name == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1332 return NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1333
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1334 str = g_utf8_strdown(name, -1);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1335 if (strstr(str, "=")) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1336 dn = str;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1337 } else {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1338 /* Assume that we have a display id instead of a dn */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1339 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
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 /* Find contact object in reference table */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1343 if (dn) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1344 contact = (NMContact *) g_hash_table_lookup(user->contacts, dn);
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
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1347 g_free(str);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1348 return contact;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1349 }
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 GList *
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1352 nm_find_contacts(NMUser * user, const char *dn)
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 guint32 i, cnt;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1355 NMFolder *folder;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1356 NMContact *contact;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1357 GList *contacts = NULL;
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 if (user == NULL || dn == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1360 return NULL;
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 /* Check for contact at the root */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1363 contact = nm_folder_find_contact(user->root_folder, dn);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1364 if (contact) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1365 contacts = g_list_append(contacts, contact);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1366 contact = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1367 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1368
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1369 /* Check for contact in each subfolder */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1370 cnt = nm_folder_get_subfolder_count(user->root_folder);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1371 for (i = 0; i < cnt; i++) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1372 folder = nm_folder_get_subfolder(user->root_folder, i);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1373 contact = nm_folder_find_contact(folder, dn);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1374 if (contact) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1375 contacts = g_list_append(contacts, contact);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1376 contact = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1377 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1378 }
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 return contacts;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1381 }
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 NMUserRecord *
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1384 nm_find_user_record(NMUser * user, const char *name)
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 char *str = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1387 const char *dn = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1388 NMUserRecord *user_record = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1389
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1390 if (user == NULL || name == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1391 return NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1392
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1393 str = g_utf8_strdown(name, -1);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1394 if (strstr(str, "=")) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1395 dn = str;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1396 } else {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1397 /* Assume that we have a display id instead of a dn */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1398 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
1399 }
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 /* Find user record in reference table */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1402 if (dn) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1403 user_record =
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1404 (NMUserRecord *) g_hash_table_lookup(user->user_records, dn);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1405 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1406
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1407 g_free(str);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1408 return user_record;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1409 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1410
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1411 const char *
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1412 nm_lookup_dn(NMUser * user, const char *display_id)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1413 {
8744
0f73e8204529 [gaim-migrate @ 9499]
Luke Schierer <lschiere@pidgin.im>
parents: 8684
diff changeset
1414 const char *dn;
0f73e8204529 [gaim-migrate @ 9499]
Luke Schierer <lschiere@pidgin.im>
parents: 8684
diff changeset
1415 char *lower;
0f73e8204529 [gaim-migrate @ 9499]
Luke Schierer <lschiere@pidgin.im>
parents: 8684
diff changeset
1416
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1417 if (user == NULL || display_id == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1418 return NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1419
8744
0f73e8204529 [gaim-migrate @ 9499]
Luke Schierer <lschiere@pidgin.im>
parents: 8684
diff changeset
1420 lower = g_utf8_strdown(display_id, -1);
0f73e8204529 [gaim-migrate @ 9499]
Luke Schierer <lschiere@pidgin.im>
parents: 8684
diff changeset
1421 dn = g_hash_table_lookup(user->display_id_to_dn, lower);
0f73e8204529 [gaim-migrate @ 9499]
Luke Schierer <lschiere@pidgin.im>
parents: 8684
diff changeset
1422 g_free(lower);
0f73e8204529 [gaim-migrate @ 9499]
Luke Schierer <lschiere@pidgin.im>
parents: 8684
diff changeset
1423
0f73e8204529 [gaim-migrate @ 9499]
Luke Schierer <lschiere@pidgin.im>
parents: 8684
diff changeset
1424 return dn;
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1425 }
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 NMFolder *
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1428 nm_find_folder(NMUser * user, const char *name)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1429 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1430 NMFolder *folder = NULL, *temp;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1431 int i, num_folders;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1432 const char *tname = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1433
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1434 if (user == NULL || name == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1435 return NULL;
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 if (*name == '\0')
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1438 return user->root_folder;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1439
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1440 num_folders = nm_folder_get_subfolder_count(user->root_folder);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1441 for (i = 0; i < num_folders; i++) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1442 temp = nm_folder_get_subfolder(user->root_folder, i);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1443 tname = nm_folder_get_name(temp);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1444 if (tname && (strcmp(tname, name) == 0)) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1445 folder = temp;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1446 break;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1447 }
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
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1450 return folder;
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
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1453 NMFolder *
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1454 nm_find_folder_by_id(NMUser * user, int object_id)
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 NMFolder *folder = NULL, *temp;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1457 int i, num_folders;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1458
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1459 if (user == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1460 return NULL;
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 if (object_id == 0)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1463 return user->root_folder;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1464
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1465 num_folders = nm_folder_get_subfolder_count(user->root_folder);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1466 for (i = 0; i < num_folders; i++) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1467 temp = nm_folder_get_subfolder(user->root_folder, i);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1468 if (nm_folder_get_id(temp) == object_id) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1469 folder = temp;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1470 break;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1471 }
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 return folder;
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 static void
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1478 _handle_multiple_get_details_login_cb(NMUser * user, NMERR_T ret_code,
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1479 gpointer resp_data, gpointer user_data)
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1480 {
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1481 nm_response_cb cb;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1482 NMRequest *request = user_data;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1483
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1484 if (user == NULL || request == NULL)
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1485 return;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1486
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1487 if ((cb = nm_request_get_callback(request))) {
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1488 cb(user, ret_code, nm_request_get_data(request),
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1489 nm_request_get_user_define(request));
9268
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
1490 nm_release_request(request);
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1491 }
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1492 }
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1493
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1494 static void
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1495 _handle_multiple_get_details_joinconf_cb(NMUser * user, NMERR_T ret_code,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1496 gpointer resp_data, gpointer user_data)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1497 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1498 NMRequest *request = user_data;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1499 NMUserRecord *user_record = resp_data;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1500 NMConference *conference;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1501 GSList *list, *node;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1502
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1503 if (user == NULL || resp_data == NULL || user_data == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1504 return;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1505
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1506 conference = nm_request_get_data(request);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1507 list = nm_request_get_user_define(request);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1508
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1509 if (ret_code == 0 && conference && list) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1510
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1511 /* Add the user to the conference */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1512 nm_conference_add_participant(conference, user_record);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1513
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1514 /* Find the user in the list and remove it */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1515 for (node = list; node; node = node->next) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1516 if (nm_utf8_str_equal(nm_user_record_get_dn(user_record),
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1517 (const char *) node->data)) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1518 list = g_slist_remove(list, node->data);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1519 nm_request_set_user_define(request, list);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1520 g_free(node->data);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1521 break;
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 }
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 /* Time to callback? */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1526 if (g_slist_length(list) == 0) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1527 nm_response_cb cb = nm_request_get_callback(request);
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 if (cb) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1530 cb(user, 0, conference, conference);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1531 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1532 g_slist_free(list);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1533 nm_release_request(request);
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 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1536 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1537
12412
a88ca6da0b38 [gaim-migrate @ 14719]
Richard Laager <rlaager@wiktel.com>
parents: 11318
diff changeset
1538 static NMERR_T
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1539 nm_call_handler(NMUser * user, NMRequest * request, NMField * fields)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1540 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1541 NMERR_T rc = NM_OK, ret_code = NM_OK;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1542 NMConference *conf = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1543 NMUserRecord *user_record = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1544 NMField *locate = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1545 NMField *field = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1546 const char *cmd;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1547 nm_response_cb cb;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1548 gboolean done = TRUE;
8684
046dd8ef2920 [gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents: 8675
diff changeset
1549
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1550 if (user == NULL || request == NULL || fields == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1551 return NMERR_BAD_PARM;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1552
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1553 /* Get the return code */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1554 field = nm_locate_field(NM_A_SZ_RESULT_CODE, fields);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1555 if (field) {
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1556 ret_code = atoi((char *) field->ptr_value);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1557 } else {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1558 ret_code = NMERR_PROTOCOL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1559 }
8684
046dd8ef2920 [gaim-migrate @ 9437]
Christian Hammond <chipx86@chipx86.com>
parents: 8675
diff changeset
1560
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1561 cmd = nm_request_get_cmd(request);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1562 if (ret_code == NM_OK && cmd != NULL) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1563
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1564 if (strcmp("login", cmd) == 0) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1565
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1566 user->user_record = nm_create_user_record_from_fields(fields);
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 /* Save the users fields */
8744
0f73e8204529 [gaim-migrate @ 9499]
Luke Schierer <lschiere@pidgin.im>
parents: 8684
diff changeset
1569 user->fields = nm_copy_field_array(fields);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1570
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1571 nm_create_contact_list(user);
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1572 done = _create_privacy_list(user, request);
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1573
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1574 } else if (strcmp("setstatus", cmd) == 0) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1575
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1576 /* Nothing to do */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1577
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1578 } else if (strcmp("createconf", cmd) == 0) {
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 conf = (NMConference *) nm_request_get_data(request);
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 /* get the convo guid */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1583 locate = nm_locate_field(NM_A_FA_CONVERSATION, fields);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1584 if (locate) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1585 field =
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1586 nm_locate_field(NM_A_SZ_OBJECT_ID, (NMField *) fields->ptr_value);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1587 if (field) {
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1588 nm_conference_set_guid(conf, (char *) field->ptr_value);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1589 }
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 nm_conference_list_add(user, conf);
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1593 nm_release_conference(conf);
8675
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 } else if (strcmp("leaveconf", cmd) == 0) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1596
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1597 conf = (NMConference *) nm_request_get_data(request);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1598 nm_conference_list_remove(user, conf);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1599
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1600 } else if (strcmp("joinconf", cmd) == 0) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1601 GSList *list = NULL, *node;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1602
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1603 conf = nm_request_get_data(request);
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 locate = nm_locate_field(NM_A_FA_CONTACT_LIST, fields);
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1606 if (locate && locate->ptr_value != 0) {
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1607
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1608 field = (NMField *) locate->ptr_value;
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1609 while ((field = nm_locate_field(NM_A_SZ_DN, field))) {
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1610 if (field && field->ptr_value != 0) {
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1611
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1612 if (nm_utf8_str_equal
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1613 (nm_user_record_get_dn(user->user_record),
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1614 (const char *) field->ptr_value)) {
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1615 field++;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1616 continue;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1617 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1618
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1619 user_record =
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1620 nm_find_user_record(user,
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1621 (const char *) field->ptr_value);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1622 if (user_record == NULL) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1623 list =
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1624 g_slist_append(list,
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1625 g_strdup((char *) field->ptr_value));
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1626 } else {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1627 nm_conference_add_participant(conf, user_record);
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 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1630 field++;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1631 }
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 if (list != NULL) {
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 done = FALSE;
9268
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
1636 nm_request_set_user_define(request, list);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1637 nm_request_add_ref(request);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1638 for (node = list; node; node = node->next) {
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 nm_send_get_details(user, (const char *) node->data,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1641 _handle_multiple_get_details_joinconf_cb,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1642 request);
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 }
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 } else if (strcmp("getdetails", cmd) == 0) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1648
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1649 locate = nm_locate_field(NM_A_FA_RESULTS, fields);
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1650 while (locate && locate->ptr_value != 0) {
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1651
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1652 user_record = nm_create_user_record_from_fields(locate);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1653 if (user_record) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1654 NMUserRecord *tmp;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1655
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1656 tmp =
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1657 nm_find_user_record(user,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1658 nm_user_record_get_dn(user_record));
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1659 if (tmp) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1660
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1661 /* Update the existing user record */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1662 nm_user_record_copy(tmp, user_record);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1663 nm_release_user_record(user_record);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1664 user_record = tmp;
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 } else {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1667 nm_user_add_user_record(user, user_record);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1668 nm_release_user_record(user_record);
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
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1671 /* Response data is new user record */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1672 nm_request_set_data(request, (gpointer) user_record);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1673 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1674
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1675 locate = nm_locate_field(NM_A_FA_RESULTS, locate+1);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1676 }
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 } else if (strcmp("createfolder", cmd) == 0) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1679
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1680 _update_contact_list(user, fields);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1681
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1682 } else if (strcmp("createcontact", cmd) == 0) {
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 _update_contact_list(user, fields);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1685
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1686 locate =
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1687 nm_locate_field(NM_A_SZ_OBJECT_ID, (NMField *) fields->ptr_value);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1688 if (locate) {
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 NMContact *new_contact =
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1691 nm_folder_find_item_by_object_id(user->root_folder,
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1692 atoi((char *)locate->ptr_value));
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1693
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1694 if (new_contact) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1695
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1696 /* Add the contact to our cache */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1697 nm_user_add_contact(user, new_contact);
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 /* Set the contact as the response data */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1700 nm_request_set_data(request, (gpointer) new_contact);
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 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1703
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1704 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1705
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1706 } else if (strcmp("deletecontact", cmd) == 0) {
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 _update_contact_list(user, fields);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1709
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1710 } else if (strcmp("movecontact", cmd) == 0) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1711
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1712 _update_contact_list(user, fields);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1713
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1714 } else if (strcmp("getstatus", cmd) == 0) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1715
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1716 locate = nm_locate_field(NM_A_SZ_STATUS, fields);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1717 if (locate) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1718 nm_user_record_set_status((NMUserRecord *)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1719 nm_request_get_data(request),
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1720 atoi((char *) locate->ptr_value), NULL);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1721 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1722
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1723 } else if (strcmp("updateitem", cmd) == 0) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1724
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1725 /* Nothing extra to do here */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1726
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1727 } else if (strcmp("createblock", cmd) == 0) {
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1728 if ((locate = nm_locate_field(NM_A_BLOCKING_DENY_LIST, fields))) {
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1729 if (locate->ptr_value) {
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1730 user->deny_list = g_slist_append(user->deny_list, g_strdup((char *)locate->ptr_value));
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1731 }
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1732 } else if ((locate = nm_locate_field(NM_A_BLOCKING_ALLOW_LIST, fields))) {
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1733 if (locate->ptr_value) {
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1734 user->allow_list = g_slist_append(user->allow_list, g_strdup((char *)locate->ptr_value));
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1735 }
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1736 }
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1737 } else if (strcmp("updateblocks", cmd) == 0) {
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1738 /* nothing to do here */
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1739 } else {
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 /* Nothing to do, just print debug message */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1742 gaim_debug(GAIM_DEBUG_INFO, "novell",
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1743 "nm_call_handler(): Unknown request command, %s\n", cmd);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1744
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1745 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1746 }
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 if (done && (cb = nm_request_get_callback(request))) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1749
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1750 cb(user, ret_code, nm_request_get_data(request),
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1751 nm_request_get_user_define(request));
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
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1754 return rc;
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
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1757 static NMERR_T
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1758 nm_process_response(NMUser * user)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1759 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1760 NMERR_T rc = NM_OK;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1761 NMField *fields = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1762 NMField *field = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1763 NMConn *conn = user->conn;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1764 NMRequest *req = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1765
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1766 rc = nm_read_header(conn);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1767 if (rc == NM_OK) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1768 rc = nm_read_fields(conn, -1, &fields);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1769 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1770
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1771 if (rc == NM_OK) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1772 field = nm_locate_field(NM_A_SZ_TRANSACTION_ID, fields);
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1773 if (field != NULL && field->ptr_value != 0) {
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1774 req = nm_conn_find_request(conn, atoi((char *) field->ptr_value));
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1775 if (req != NULL) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1776 rc = nm_call_handler(user, req, fields);
9268
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
1777 nm_conn_remove_request_item(conn, req);
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1778 }
9268
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
1779
8675
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
8744
0f73e8204529 [gaim-migrate @ 9499]
Luke Schierer <lschiere@pidgin.im>
parents: 8684
diff changeset
1783 if (fields)
0f73e8204529 [gaim-migrate @ 9499]
Luke Schierer <lschiere@pidgin.im>
parents: 8684
diff changeset
1784 nm_free_fields(&fields);
0f73e8204529 [gaim-migrate @ 9499]
Luke Schierer <lschiere@pidgin.im>
parents: 8684
diff changeset
1785
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1786 return rc;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1787 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1788
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1789 /*
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1790 * Some utility functions...haven't figured out where
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1791 * they belong yet.
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1792 */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1793 gint
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1794 nm_utf8_strcasecmp(gconstpointer str1, gconstpointer str2)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1795 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1796 gint rv;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1797 char *str1_down = g_utf8_strdown(str1, -1);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1798 char *str2_down = g_utf8_strdown(str2, -1);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1799
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1800 rv = g_utf8_collate(str1_down, str2_down);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1801
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1802 g_free(str1_down);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1803 g_free(str2_down);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1804
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1805 return rv;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1806 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1807
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1808 gboolean
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1809 nm_utf8_str_equal(gconstpointer str1, gconstpointer str2)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1810 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1811 return (nm_utf8_strcasecmp(str1, str2) == 0);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1812 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1813
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1814 char *
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1815 nm_typed_to_dotted(const char *typed)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1816 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1817 unsigned i = 0, j = 0;
8782
5a2b5e4abf3a [gaim-migrate @ 9544]
Christian Hammond <chipx86@chipx86.com>
parents: 8744
diff changeset
1818 char *dotted;
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1819
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1820 if (typed == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1821 return NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1822
8782
5a2b5e4abf3a [gaim-migrate @ 9544]
Christian Hammond <chipx86@chipx86.com>
parents: 8744
diff changeset
1823 dotted = g_new0(char, strlen(typed));
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1824
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1825 do {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1826
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1827 /* replace comma with a dot */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1828 if (j != 0) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1829 dotted[j] = '.';
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1830 j++;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1831 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1832
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1833 /* skip the type */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1834 while (typed[i] != '\0' && typed[i] != '=')
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1835 i++;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1836
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1837 /* verify that we aren't running off the end */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1838 if (typed[i] == '\0') {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1839 dotted[j] = '\0';
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1840 break;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1841 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1842
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1843 i++;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1844
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1845 /* copy the object name to context */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1846 while (typed[i] != '\0' && typed[i] != ',') {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1847 dotted[j] = typed[i];
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1848 j++;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1849 i++;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1850 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1851
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1852 } while (typed[i] != '\0');
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1853
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1854 return dotted;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1855 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1856
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1857 const char *
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1858 nm_error_to_string(NMERR_T err)
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1859 {
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1860 static char *unknown_msg = NULL;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1861
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1862 g_free(unknown_msg);
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1863 unknown_msg = NULL;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1864
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1865 switch (err) {
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1866
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1867 case NMERR_BAD_PARM:
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1868 return _("Required parameters not passed in");
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1869
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1870 case NMERR_TCP_WRITE:
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1871 return _("Unable to write to network");
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1872
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1873 case NMERR_TCP_READ:
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1874 return _("Unable to read from network");
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1875
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1876 case NMERR_PROTOCOL:
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1877 return _("Error communicating with server");
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1878
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1879 case NMERR_CONFERENCE_NOT_FOUND:
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1880 case NMERR_CONFERENCE_NOT_FOUND_2:
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1881 return _("Conference not found");
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1882
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1883 case NMERR_CONFERENCE_NOT_INSTANTIATED:
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1884 return _("Conference does not exist");
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1885
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1886 case NMERR_DUPLICATE_FOLDER:
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1887 case NMERR_FOLDER_EXISTS:
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1888 return _("A folder with that name already exists");
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1889
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1890 case NMERR_NOT_SUPPORTED:
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1891 return _("Not supported");
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1892
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1893 case NMERR_PASSWORD_EXPIRED:
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1894 case NMERR_PASSWORD_EXPIRED_2:
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1895 return _("Password has expired");
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1896
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1897 case NMERR_PASSWORD_INVALID:
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1898 return _("Invalid password");
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1899
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1900 case NMERR_USER_NOT_FOUND:
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1901 return _("User not found");
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1902
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1903 case NMERR_USER_DISABLED:
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1904 return _("Account has been disabled");
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1905
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1906 case NMERR_DIRECTORY_FAILURE:
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1907 return _("The server could not access the directory");
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1908
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1909 case NMERR_ADMIN_LOCKED:
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1910 return _("Your system administrator has disabled this operation");
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1911
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1912 case NMERR_SERVER_BUSY:
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1913 return _("The server is unavailable; try again later");
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1914
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1915 case NMERR_DUPLICATE_CONTACT:
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1916 return _("Cannot add a contact to the same folder twice");
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1917
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1918 case NMERR_USER_NOT_ALLOWED:
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1919 return _("Cannot add yourself");
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1920
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1921 case NMERR_MASTER_ARCHIVE_MISSING:
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1922 return _("Master archive is misconfigured");
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1923
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1924 case NMERR_AUTHENTICATION_FAILED:
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1925 case NMERR_CREDENTIALS_MISSING:
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1926 return _("Invalid username or password");
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1927
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1928 case NMERR_HOST_NOT_FOUND:
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1929 return _("Could not recognize the host of the username you entered");
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1930
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1931 case NMERR_ACCESS_DENIED:
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1932 return _("Your account has been disabled because too many invalid passwords were entered");
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1934 case NMERR_DUPLICATE_PARTICIPANT:
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1935 return _("You cannot add the same person twice to a conversation");
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1936
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1937 case NMERR_TOO_MANY_CONTACTS:
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1938 case NMERR_TOO_MANY_FOLDERS:
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1939 return _("You have reached your limit for the number of contacts allowed");
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1940
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1941 case NMERR_OBJECT_NOT_FOUND:
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1942 return _("You have entered an invalid username");
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1943
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1944 case NMERR_DIRECTORY_UPDATE:
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1945 return _("An error occurred while updating the directory");
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1946
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1947 case NMERR_SERVER_PROTOCOL:
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1948 return _("Incompatible protocol version");
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1949
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1950 case NMERR_USER_BLOCKED:
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1951 return _("The user has blocked you");
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1952
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1953 case NMERR_EVAL_CONNECTION_LIMIT:
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1954 return _("This evaluation version does not allow more than ten users to log in at one time");
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1955
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1956 case NMERR_CONVERSATION_INVITE:
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1957 return _("The user is either offline or you are blocked");
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1958
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1959 default:
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1960 unknown_msg = g_strdup_printf (_("Unknown error: 0x%X"), err);
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1961
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1962 return unknown_msg;
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1963 }
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1964 }
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1965
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1966 static void
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1967 _update_contact_list(NMUser * user, NMField * fields)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1968 {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1969 NMField *list, *cursor, *locate;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1970 gint objid1;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1971 NMContact *contact;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1972 NMFolder *folder;
8782
5a2b5e4abf3a [gaim-migrate @ 9544]
Christian Hammond <chipx86@chipx86.com>
parents: 8744
diff changeset
1973 gpointer item;
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1974
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1975 if (user == NULL || fields == NULL)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1976 return;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1977
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1978 /* Is it wrapped in a RESULTS array? */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1979 if (strcmp(fields->tag, NM_A_FA_RESULTS) == 0) {
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1980 list = (NMField *) fields->ptr_value;
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1981 } else {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1982 list = fields;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1983 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1984
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1985 /* Update the cached contact list */
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1986 cursor = (NMField *) list->ptr_value;
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1987 while (cursor->tag != NULL) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1988 if ((g_ascii_strcasecmp(cursor->tag, NM_A_FA_CONTACT) == 0) ||
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1989 (g_ascii_strcasecmp(cursor->tag, NM_A_FA_FOLDER) == 0)) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1990
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1991 locate =
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1992 nm_locate_field(NM_A_SZ_OBJECT_ID, (NMField *) cursor->ptr_value);
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1993 if (locate != NULL && locate->ptr_value != 0) {
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
1994 objid1 = atoi((char *) locate->ptr_value);
8782
5a2b5e4abf3a [gaim-migrate @ 9544]
Christian Hammond <chipx86@chipx86.com>
parents: 8744
diff changeset
1995 item =
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1996 nm_folder_find_item_by_object_id(user->root_folder, objid1);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1997 if (item != NULL) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1998 if (cursor->method == NMFIELD_METHOD_ADD) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1999 if (g_ascii_strcasecmp(cursor->tag, NM_A_FA_CONTACT) == 0) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2000 contact = (NMContact *) item;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2001 nm_contact_update_list_properties(contact, cursor);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2002 } else if (g_ascii_strcasecmp(cursor->tag, NM_A_FA_FOLDER)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2003 == 0) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2004 folder = (NMFolder *) item;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2005 nm_folder_update_list_properties(folder, cursor);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2006 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2007 } else if (cursor->method == NMFIELD_METHOD_DELETE) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2008 if (g_ascii_strcasecmp(cursor->tag, NM_A_FA_CONTACT) == 0) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2009 contact = (NMContact *) item;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2010 folder =
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2011 nm_find_folder_by_id(user,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2012 nm_contact_get_parent_id
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2013 (contact));
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2014 if (folder) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2015 nm_folder_remove_contact(folder, contact);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2016 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2017 } else if (g_ascii_strcasecmp(cursor->tag, NM_A_FA_FOLDER)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2018 == 0) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2019 /* TODO: write nm_folder_remove_folder */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2020 /* ignoring for now, should not be a big deal */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2021 /* folder = (NMFolder *) item;*/
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2022 /* nm_folder_remove_folder(user->root_folder, folder);*/
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2023 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2024 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2025 } else {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2026
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2027 if (cursor->method == NMFIELD_METHOD_ADD) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2028
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2029 /* Not found, so we need to add it */
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2030 if (g_ascii_strcasecmp(cursor->tag, NM_A_FA_CONTACT) == 0) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2031
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2032 const char *dn = NULL;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2033
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2034 locate =
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2035 nm_locate_field(NM_A_SZ_DN,
8933
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
2036 (NMField *) cursor->ptr_value);
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
2037 if (locate != NULL && locate->ptr_value != 0) {
6663ad2386d9 [gaim-migrate @ 9703]
Luke Schierer <lschiere@pidgin.im>
parents: 8874
diff changeset
2038 dn = (const char *) locate->ptr_value;
8675
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2039 if (dn != NULL) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2040 contact =
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2041 nm_create_contact_from_fields(cursor);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2042 if (contact) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2043 nm_folder_add_contact_to_list(user->
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2044 root_folder,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2045 contact);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2046 nm_release_contact(contact);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2047 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2048 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2049 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2050 } else if (g_ascii_strcasecmp(cursor->tag, NM_A_FA_FOLDER)
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2051 == 0) {
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2052 folder = nm_create_folder_from_fields(cursor);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2053 nm_folder_add_folder_to_list(user->root_folder,
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2054 folder);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2055 nm_release_folder(folder);
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2056 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2057 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2058 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2059 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2060 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2061 cursor++;
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2062 }
9ee2542d1104 [gaim-migrate @ 9428]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2063 }
9268
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2064
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2065 static char *
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2066 nm_rtfize_text(char *text)
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2067 {
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2068 GString *gstr = NULL;
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2069 unsigned char *pch;
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2070 char *uni_str = NULL, *rtf = NULL;
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2071 int bytes;
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2072 gunichar uc;
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2073
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2074 gstr = g_string_sized_new(strlen(text)*2);
11318
519dc2186438 [gaim-migrate @ 13521]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9360
diff changeset
2075 pch = (unsigned char *)text;
9268
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2076 while (*pch) {
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2077 if ((*pch) <= 0x7F) {
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2078 switch (*pch) {
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2079 case '{':
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2080 case '}':
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2081 case '\\':
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2082 gstr = g_string_append_c(gstr, '\\');
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2083 gstr = g_string_append_c(gstr, *pch);
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2084 break;
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2085 case '\n':
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2086 gstr = g_string_append(gstr, "\\par ");
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2087 break;
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2088 default:
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2089 gstr = g_string_append_c(gstr, *pch);
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2090 break;
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2091 }
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2092 pch++;
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2093 } else {
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2094 /* convert the utf-8 character to ucs-4 for rtf encoding */
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2095 if(*pch <= 0xDF) {
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2096 uc = ((((gunichar)pch[0]) & 0x001F) << 6) |
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2097 (((gunichar)pch[1]) & 0x003F);
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2098 bytes = 2;
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2099 } else if(*pch <= 0xEF) {
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2100 uc = ((((gunichar)pch[0]) & 0x000F) << 12) |
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2101 ((((gunichar)pch[1]) & 0x003F) << 6) |
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2102 (((gunichar)pch[2]) & 0x003F);
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2103 bytes = 3;
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2104 } else if (*pch <= 0xF7) {
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2105 uc = ((((gunichar)pch[0]) & 0x0007) << 18) |
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2106 ((((gunichar)pch[1]) & 0x003F) << 12) |
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2107 ((((gunichar)pch[2]) & 0x003F) << 6) |
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2108 (((gunichar)pch[3]) & 0x003F);
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2109 bytes = 4;
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2110 } else if (*pch <= 0xFB) {
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2111 uc = ((((gunichar)pch[0]) & 0x0003) << 24) |
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2112 ((((gunichar)pch[1]) & 0x003F) << 18) |
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2113 ((((gunichar)pch[2]) & 0x003F) << 12) |
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2114 ((((gunichar)pch[3]) & 0x003F) << 6) |
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2115 (((gunichar)pch[4]) & 0x003F);
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2116 bytes = 5;
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2117 } else if (*pch <= 0xFD) {
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2118 uc = ((((gunichar)pch[0]) & 0x0001) << 30) |
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2119 ((((gunichar)pch[1]) & 0x003F) << 24) |
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2120 ((((gunichar)pch[2]) & 0x003F) << 18) |
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2121 ((((gunichar)pch[3]) & 0x003F) << 12) |
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2122 ((((gunichar)pch[4]) & 0x003F) << 6) |
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2123 (((gunichar)pch[5]) & 0x003F);
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2124 bytes = 6;
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2125 } else {
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2126 /* should never happen ... bogus utf-8! */
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2127 gaim_debug_info("novell", "bogus utf-8 lead byte: 0x%X\n", pch[0]);
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2128 uc = 0x003F;
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2129 bytes = 1;
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2130 }
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2131 uni_str = g_strdup_printf("\\u%d?", uc);
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2132 gaim_debug_info("novell", "unicode escaped char %s\n", uni_str);
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2133 gstr = g_string_append(gstr, uni_str);
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2134 pch += bytes;
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2135 g_free(uni_str);
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2136 }
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2137 }
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2138
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2139 rtf = g_strdup_printf(RTF_TEMPLATE, gstr->str);
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2140 g_string_free(gstr, TRUE);
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2141 return rtf;
54fb1f466953 [gaim-migrate @ 10069]
Luke Schierer <lschiere@pidgin.im>
parents: 8933
diff changeset
2142 }