Mercurial > pidgin
annotate src/protocols/msn/sync.c @ 12116:e75ef7aa913e
[gaim-migrate @ 14416]
" This patch implements a replacement for the queuing
system from 1.x. It also obsoletes a previous patch
[#1338873] I submitted to prioritize the unseen states
in gtk conversations.
The attached envelope.png is ripped from the
msgunread.png already included in gaim. It should be
dropped in the pixmaps directory (Makefile.am is
updated accordingly in this patch).
The two separate queuing preferences from 1.x, queuing
messages while away and queuing all new messages (from
docklet), are replaced with a single 3-way preference
for conversations. The new preference is "Hide new IM
conversations". This preference can be set to never,
away and always.
When a gtk conversation is created, it may be placed in
a hidden conversation window instead of being placed
normally. This decision is based upon the preference
and possibly the away state of the account the
conversation is being created for. This *will* effect
conversations the user explicitly requests to be
created, so in these cases the caller must be sure to
present the conversation to the user, using
gaim_gtkconv_present_conversation(). This is done
already in gtkdialogs.c which handles creating
conversations requested by the user from gaim proper
(menus, double-clicking on budy in blist, etc.).
The main advantage to not queuing messages is that the
conversations exist, the message is written to the
conversation (and logged if appropriate) and the unseen
state is set on the conversation. This means no
additional features are needed to track whether there
are queued messages or not, just use the unseen state
on conversations.
Since conversations may not be visible (messages
"queued"), gaim proper needs some notification that
there are messages waiting. I opted for a menutray icon
that shows up when an im conversation has an unseen
message. Clicking this icon will focus (and show if
hidden) the first conversation with an unseen message.
This is essentially the same behavior of the docklet in
cvs right now, except that the icon is only visible
when there is a conversation with an unread message.
The api that is added is flexible enough to allow
either the docklet or the new blist menutray icon to be
visible for conversations of any/all types and for
unseen messages >= any state. Currently they are set to
only IM conversations and only unseen states >= TEXT
(system messages and no log messages will not trigger
blinking the docklet or showing the blist tray icon),
but these could be made preferences relatively easily
in the future. Other plugins could probably benefit as
well: gaim_gtk_conversations_get_first_unseen().
There is probably some limit to comment size, so I'll
stop rambling now. If anyone has more
questions/comments, catch me in #gaim, here or on
gaim-devel."
committer: Tailor Script <tailor@pidgin.im>
| author | Luke Schierer <lschiere@pidgin.im> |
|---|---|
| date | Wed, 16 Nov 2005 18:17:01 +0000 |
| parents | 92d4a25fd33c |
| children | 967ef719cb62 |
| rev | line source |
|---|---|
|
9198
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
1 /** |
|
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
2 * @file sync.c MSN list synchronization functions |
|
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
3 * |
|
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
4 * gaim |
|
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
5 * |
|
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
6 * Gaim is the legal property of its developers, whose names are too numerous |
|
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
7 * to list here. Please refer to the COPYRIGHT file distributed with this |
|
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
8 * source distribution. |
|
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
9 * |
|
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
10 * This program is free software; you can redistribute it and/or modify |
|
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
11 * it under the terms of the GNU General Public License as published by |
|
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
12 * the Free Software Foundation; either version 2 of the License, or |
|
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
13 * (at your option) any later version. |
|
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
14 * |
|
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
15 * This program is distributed in the hope that it will be useful, |
|
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
18 * GNU General Public License for more details. |
|
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
19 * |
|
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
20 * You should have received a copy of the GNU General Public License |
|
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
21 * along with this program; if not, write to the Free Software |
|
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
23 */ |
| 9193 | 24 #include "msn.h" |
| 25 #include "sync.h" | |
| 26 #include "state.h" | |
| 27 | |
| 28 static MsnTable *cbs_table; | |
| 29 | |
| 30 static void | |
| 31 blp_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) | |
| 32 { | |
| 33 GaimConnection *gc = cmdproc->session->account->gc; | |
| 34 const char *list_name; | |
| 35 | |
| 36 list_name = cmd->params[0]; | |
| 37 | |
| 38 if (!g_ascii_strcasecmp(list_name, "AL")) | |
| 39 { | |
| 40 /* | |
| 41 * If the current setting is AL, messages from users who | |
| 42 * are not in BL will be delivered. | |
| 43 * | |
| 44 * In other words, deny some. | |
| 45 */ | |
| 46 gc->account->perm_deny = GAIM_PRIVACY_DENY_USERS; | |
| 47 } | |
| 48 else | |
| 49 { | |
| 50 /* If the current setting is BL, only messages from people | |
| 51 * who are in the AL will be delivered. | |
| 52 * | |
| 53 * In other words, permit some. | |
| 54 */ | |
| 55 gc->account->perm_deny = GAIM_PRIVACY_ALLOW_USERS; | |
| 56 } | |
| 57 } | |
| 58 | |
| 59 static void | |
| 60 prp_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) | |
| 61 { | |
| 62 MsnSession *session = cmdproc->session; | |
| 63 const char *type, *value; | |
| 64 | |
| 65 type = cmd->params[0]; | |
| 66 value = cmd->params[1]; | |
| 67 | |
| 68 if (cmd->param_count == 2) | |
| 69 { | |
| 70 if (!strcmp(type, "PHH")) | |
| 71 msn_user_set_home_phone(session->user, gaim_url_decode(value)); | |
| 72 else if (!strcmp(type, "PHW")) | |
| 73 msn_user_set_work_phone(session->user, gaim_url_decode(value)); | |
| 74 else if (!strcmp(type, "PHM")) | |
| 75 msn_user_set_mobile_phone(session->user, gaim_url_decode(value)); | |
| 76 } | |
| 77 else | |
| 78 { | |
| 79 if (!strcmp(type, "PHH")) | |
| 80 msn_user_set_home_phone(session->user, NULL); | |
| 81 else if (!strcmp(type, "PHW")) | |
| 82 msn_user_set_work_phone(session->user, NULL); | |
| 83 else if (!strcmp(type, "PHM")) | |
| 84 msn_user_set_mobile_phone(session->user, NULL); | |
| 85 } | |
| 86 } | |
| 87 | |
| 88 static void | |
| 89 lsg_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) | |
| 90 { | |
| 91 MsnSession *session = cmdproc->session; | |
| 92 MsnGroup *group; | |
| 93 GaimGroup *g; | |
| 94 const char *name; | |
| 95 int group_id; | |
| 96 | |
| 97 group_id = atoi(cmd->params[0]); | |
| 98 name = gaim_url_decode(cmd->params[1]); | |
| 99 | |
| 100 group = msn_group_new(session->userlist, group_id, name); | |
| 101 | |
| 10451 | 102 /* HACK */ |
| 103 if (group_id == 0) | |
| 104 /* Group of ungroupped buddies */ | |
| 105 return; | |
| 106 | |
| 9193 | 107 if ((g = gaim_find_group(name)) == NULL) |
| 108 { | |
| 109 g = gaim_group_new(name); | |
| 110 gaim_blist_add_group(g, NULL); | |
| 111 } | |
| 112 } | |
| 113 | |
| 114 static void | |
| 115 lst_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) | |
| 116 { | |
| 117 MsnSession *session = cmdproc->session; | |
| 118 char *passport = NULL; | |
| 119 const char *friend = NULL; | |
| 120 int list_op; | |
| 121 MsnUser *user; | |
| 122 | |
| 10044 | 123 passport = cmd->params[0]; |
| 124 friend = gaim_url_decode(cmd->params[1]); | |
| 125 list_op = atoi(cmd->params[2]); | |
|
9225
554ef91db2dd
[gaim-migrate @ 10021]
Christian Hammond <chipx86@chipx86.com>
parents:
9198
diff
changeset
|
126 |
| 9193 | 127 user = msn_user_new(session->userlist, passport, friend); |
| 128 | |
| 129 msn_userlist_add_user(session->userlist, user); | |
| 130 | |
| 131 session->sync->last_user = user; | |
| 132 | |
| 133 /* TODO: This can be improved */ | |
|
9198
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
134 |
| 9193 | 135 if (list_op & MSN_LIST_FL_OP) |
| 136 { | |
| 137 char **c; | |
| 138 char **tokens; | |
| 139 const char *group_nums; | |
| 140 GSList *group_ids; | |
| 141 | |
| 142 group_nums = cmd->params[3]; | |
| 143 | |
| 144 group_ids = NULL; | |
| 145 | |
| 146 tokens = g_strsplit(group_nums, ",", -1); | |
| 147 | |
| 148 for (c = tokens; *c != NULL; c++) | |
| 149 { | |
| 150 int id; | |
| 151 | |
| 152 id = atoi(*c); | |
| 153 group_ids = g_slist_append(group_ids, GINT_TO_POINTER(id)); | |
| 154 } | |
|
9198
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9193
diff
changeset
|
155 |
| 9193 | 156 g_strfreev(tokens); |
| 157 | |
| 158 msn_got_lst_user(session, user, list_op, group_ids); | |
| 159 | |
| 160 g_slist_free(group_ids); | |
| 161 } | |
| 162 else | |
| 163 { | |
| 164 msn_got_lst_user(session, user, list_op, NULL); | |
| 165 } | |
| 166 | |
| 167 session->sync->num_users++; | |
| 168 | |
| 169 if (session->sync->num_users == session->sync->total_users) | |
| 170 { | |
| 171 cmdproc->cbs_table = session->sync->old_cbs_table; | |
| 172 | |
| 10044 | 173 msn_session_finish_login(session); |
| 9193 | 174 |
| 175 msn_sync_destroy(session->sync); | |
| 176 session->sync = NULL; | |
| 177 } | |
| 178 } | |
| 179 | |
| 180 static void | |
| 181 bpr_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) | |
| 182 { | |
| 183 MsnSync *sync = cmdproc->session->sync; | |
| 184 const char *type, *value; | |
| 185 MsnUser *user; | |
| 186 | |
| 187 user = sync->last_user; | |
| 188 | |
| 189 type = cmd->params[0]; | |
| 190 value = cmd->params[1]; | |
| 191 | |
| 192 if (value) | |
| 193 { | |
| 194 if (!strcmp(type, "MOB")) | |
| 195 { | |
| 196 if (!strcmp(value, "Y")) | |
| 197 user->mobile = TRUE; | |
| 198 } | |
| 199 else if (!strcmp(type, "PHH")) | |
| 200 msn_user_set_home_phone(user, gaim_url_decode(value)); | |
| 201 else if (!strcmp(type, "PHW")) | |
| 202 msn_user_set_work_phone(user, gaim_url_decode(value)); | |
| 203 else if (!strcmp(type, "PHM")) | |
| 204 msn_user_set_mobile_phone(user, gaim_url_decode(value)); | |
| 205 } | |
| 206 } | |
| 207 | |
| 208 void | |
| 209 msn_sync_init(void) | |
| 210 { | |
| 211 /* TODO: check prp, blp, bpr */ | |
| 212 | |
| 213 cbs_table = msn_table_new(); | |
| 214 | |
| 215 /* Syncing */ | |
| 216 msn_table_add_cmd(cbs_table, NULL, "GTC", NULL); | |
| 217 msn_table_add_cmd(cbs_table, NULL, "BLP", blp_cmd); | |
| 218 msn_table_add_cmd(cbs_table, NULL, "PRP", prp_cmd); | |
| 219 msn_table_add_cmd(cbs_table, NULL, "LSG", lsg_cmd); | |
| 220 msn_table_add_cmd(cbs_table, NULL, "LST", lst_cmd); | |
| 221 msn_table_add_cmd(cbs_table, NULL, "BPR", bpr_cmd); | |
| 222 } | |
| 223 | |
| 224 void | |
| 225 msn_sync_end(void) | |
| 226 { | |
| 227 msn_table_destroy(cbs_table); | |
| 228 } | |
| 229 | |
| 230 MsnSync * | |
| 231 msn_sync_new(MsnSession *session) | |
| 232 { | |
| 233 MsnSync *sync; | |
| 234 | |
| 235 sync = g_new0(MsnSync, 1); | |
| 236 | |
| 237 sync->session = session; | |
| 238 sync->cbs_table = cbs_table; | |
| 239 | |
| 240 return sync; | |
| 241 } | |
| 242 | |
| 243 void | |
| 244 msn_sync_destroy(MsnSync *sync) | |
| 245 { | |
| 246 g_free(sync); | |
| 247 } |
