Changeset a33ee0f
- Timestamp:
- 2016-09-20T03:39:05Z (8 years ago)
- Branches:
- master
- Children:
- 725f942
- Parents:
- 67ea361
- git-author:
- jgeboski <jgeboski@…> (22-06-16 18:54:52)
- git-committer:
- jgeboski <jgeboski@…> (20-09-16 03:39:05)
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
bitlbee.h
r67ea361 ra33ee0f 173 173 gboolean root_command_add(const char *command, int params, void (*func)(irc_t *, char **args), int flags); 174 174 gboolean cmd_identify_finish(gpointer data, gint fd, b_input_condition cond); 175 void cmd_chat_list_finish(struct im_connection *ic); 175 176 gboolean bitlbee_shutdown(gpointer data, gint fd, b_input_condition cond); 176 177 -
doc/user-guide/commands.xml
r67ea361 ra33ee0f 264 264 265 265 <bitlbee-command name="add"> 266 <syntax>chat add <account id> <room > [<channel>]</syntax>266 <syntax>chat add <account id> <room|!index> [<channel>]</syntax> 267 267 268 268 <description> … … 280 280 </description> 281 281 282 </bitlbee-command> 283 284 <bitlbee-command name="list"> 285 <syntax>chat list <account id> [<server>]</syntax> 286 287 <description> 288 <para> 289 List existing chatrooms provided by an account. BitlBee needs this to propogate an internal list of chats. The existing chat can then be added with <emphasis>chat add</emphasis>. 290 </para> 291 </description> 282 292 </bitlbee-command> 283 293 -
protocols/bee.h
r67ea361 ra33ee0f 83 83 void *data; /* Can be used by the IM module. */ 84 84 } bee_user_t; 85 86 typedef struct bee_chat_info { 87 char *title; 88 char *topic; 89 } bee_chat_info_t; 85 90 86 91 /* This one's mostly used so save space and make it easier (cheaper) to … … 185 190 G_MODULE_EXPORT void imcb_chat_invite(struct im_connection *ic, const char *name, const char *who, const char *msg); 186 191 192 G_MODULE_EXPORT void bee_chat_list_finish(struct im_connection *ic); 193 187 194 #endif /* __BEE_H__ */ -
protocols/bee_chat.c
r67ea361 ra33ee0f 274 274 } 275 275 } 276 277 void bee_chat_list_finish(struct im_connection *ic) 278 { 279 cmd_chat_list_finish(ic); 280 } -
protocols/nogaim.h
r67ea361 ra33ee0f 96 96 97 97 GSList *groupchats; 98 GSList *chatlist; 98 99 }; 99 100 … … 263 264 gboolean (* handle_is_self) (struct im_connection *, const char *who); 264 265 266 /* This sets/updates the im_connection->chatlist field with a 267 * bee_chat_info_t GSList. This function should ensure the 268 * bee_chat_list_finish() function gets called at some point 269 * after the chat list is completely updated. 270 */ 271 void (* chat_list) (struct im_connection *, const char *server); 272 265 273 /* Some placeholders so eventually older plugins may cooperate with newer BitlBees. */ 266 274 void *resv1; -
root_commands.c
r67ea361 ra33ee0f 1218 1218 1219 1219 if (g_strcasecmp(cmd[1], "add") == 0) { 1220 char *channel, *s; 1220 bee_chat_info_t *ci; 1221 char *channel, *room, *s; 1221 1222 struct irc_channel *ic; 1223 guint i; 1222 1224 1223 1225 MIN_ARGS(3); … … 1231 1233 } 1232 1234 1235 if (cmd[3][0] == '!') { 1236 if (!acc->prpl->chat_list) { 1237 irc_rootmsg(irc, "Listing chatrooms not supported on that account."); 1238 return; 1239 } 1240 1241 i = g_ascii_strtoull(cmd[3] + 1, NULL, 10); 1242 ci = g_slist_nth_data(acc->ic->chatlist, i - 1); 1243 1244 if (ci == NULL) { 1245 irc_rootmsg(irc, "Invalid chatroom index"); 1246 return; 1247 } 1248 1249 room = ci->title; 1250 } else { 1251 room = cmd[3]; 1252 } 1253 1233 1254 if (cmd[4] == NULL) { 1234 channel = g_strdup( cmd[3]);1255 channel = g_strdup(room); 1235 1256 if ((s = strchr(channel, '@'))) { 1236 1257 *s = 0; … … 1252 1273 set_setstr(&ic->set, "chat_type", "room") && 1253 1274 set_setstr(&ic->set, "account", cmd[2]) && 1254 set_setstr(&ic->set, "room", cmd[3])) {1275 set_setstr(&ic->set, "room", room)) { 1255 1276 irc_rootmsg(irc, "Chatroom successfully added."); 1256 1277 } else { … … 1262 1283 } 1263 1284 g_free(channel); 1285 } else if (g_strcasecmp(cmd[1], "list") == 0) { 1286 MIN_ARGS(2); 1287 1288 if (!(acc = account_get(irc->b, cmd[2]))) { 1289 irc_rootmsg(irc, "Invalid account"); 1290 return; 1291 } else if (!acc->prpl->chat_list) { 1292 irc_rootmsg(irc, "Listing chatrooms not supported on that account."); 1293 return; 1294 } 1295 1296 acc->prpl->chat_list(acc->ic, cmd[3]); 1264 1297 } else if (g_strcasecmp(cmd[1], "with") == 0) { 1265 1298 irc_user_t *iu; … … 1276 1309 irc_rootmsg(irc, "Can't open a groupchat with %s.", cmd[2]); 1277 1310 } 1278 } else if (g_strcasecmp(cmd[1], "list") == 0 || 1279 g_strcasecmp(cmd[1], "set") == 0 || 1311 } else if (g_strcasecmp(cmd[1], "set") == 0 || 1280 1312 g_strcasecmp(cmd[1], "del") == 0) { 1281 1313 irc_rootmsg(irc, … … 1287 1319 cmd[1]); 1288 1320 } 1321 } 1322 1323 void cmd_chat_list_finish(struct im_connection *ic) 1324 { 1325 account_t *acc = ic->acc; 1326 bee_chat_info_t *ci; 1327 char *hformat, *iformat, *topic; 1328 GSList *l; 1329 guint i = 0; 1330 irc_t *irc = ic->bee->ui_data; 1331 1332 if (ic->chatlist == NULL) { 1333 irc_rootmsg(irc, "No existing chatrooms"); 1334 return; 1335 } 1336 1337 if (strchr(irc->umode, 'b') != NULL) { 1338 hformat = "%s\t%s\t%s"; 1339 iformat = "%u\t%s\t%s"; 1340 } else { 1341 hformat = "%s %-20s %s"; 1342 iformat = "%5u %-20.20s %s"; 1343 } 1344 1345 irc_rootmsg(irc, hformat, "Index", "Title", "Topic"); 1346 1347 for (l = ic->chatlist; l; l = l->next) { 1348 ci = l->data; 1349 topic = ci->topic ? ci->topic : ""; 1350 irc_rootmsg(irc, iformat, ++i, ci->title, topic); 1351 } 1352 1353 irc_rootmsg(irc, "%u %s chatrooms", i, acc->tag); 1289 1354 } 1290 1355
Note: See TracChangeset
for help on using the changeset viewer.