comparison mcabber/src/commands.c @ 585:7eff2c1481fa

Add "/room affil" and "/room role"
author Mikael Berthe <mikael@lilotux.net>
date Sat, 10 Dec 2005 18:34:51 +0100
parents 414fbf558f1e
children 49f132b434a3
comparison
equal deleted inserted replaced
584:414fbf558f1e 585:7eff2c1481fa
154 compl_add_category_word(COMPL_MULTILINE, "begin"); 154 compl_add_category_word(COMPL_MULTILINE, "begin");
155 compl_add_category_word(COMPL_MULTILINE, "send"); 155 compl_add_category_word(COMPL_MULTILINE, "send");
156 compl_add_category_word(COMPL_MULTILINE, "verbatim"); 156 compl_add_category_word(COMPL_MULTILINE, "verbatim");
157 157
158 // Room category 158 // Room category
159 compl_add_category_word(COMPL_ROOM, "affil");
159 compl_add_category_word(COMPL_ROOM, "ban"); 160 compl_add_category_word(COMPL_ROOM, "ban");
160 compl_add_category_word(COMPL_ROOM, "invite"); 161 compl_add_category_word(COMPL_ROOM, "invite");
161 compl_add_category_word(COMPL_ROOM, "join"); 162 compl_add_category_word(COMPL_ROOM, "join");
162 compl_add_category_word(COMPL_ROOM, "kick"); 163 compl_add_category_word(COMPL_ROOM, "kick");
163 compl_add_category_word(COMPL_ROOM, "leave"); 164 compl_add_category_word(COMPL_ROOM, "leave");
164 compl_add_category_word(COMPL_ROOM, "names"); 165 compl_add_category_word(COMPL_ROOM, "names");
165 compl_add_category_word(COMPL_ROOM, "nick"); 166 compl_add_category_word(COMPL_ROOM, "nick");
166 compl_add_category_word(COMPL_ROOM, "privmsg"); 167 compl_add_category_word(COMPL_ROOM, "privmsg");
167 compl_add_category_word(COMPL_ROOM, "remove"); 168 compl_add_category_word(COMPL_ROOM, "remove");
169 compl_add_category_word(COMPL_ROOM, "role");
168 compl_add_category_word(COMPL_ROOM, "topic"); 170 compl_add_category_word(COMPL_ROOM, "topic");
169 compl_add_category_word(COMPL_ROOM, "unlock"); 171 compl_add_category_word(COMPL_ROOM, "unlock");
170 compl_add_category_word(COMPL_ROOM, "whois"); 172 compl_add_category_word(COMPL_ROOM, "whois");
171 } 173 }
172 174
1244 jb_room_invite(roomname, jid, arg); 1246 jb_room_invite(roomname, jid, arg);
1245 scr_LogPrint(LPRINT_LOGNORM, "Invitation sent to <%s>", jid); 1247 scr_LogPrint(LPRINT_LOGNORM, "Invitation sent to <%s>", jid);
1246 free_arg_lst(paramlst); 1248 free_arg_lst(paramlst);
1247 } 1249 }
1248 1250
1251 static void room_affil(gpointer bud, char *arg)
1252 {
1253 char **paramlst;
1254 gchar *jid, *rolename;
1255 struct role_affil ra;
1256 const char *roomid = buddy_getjid(bud);
1257
1258 paramlst = split_arg(arg, 3, 1); // jid, new_affil, [reason]
1259 jid = *paramlst;
1260 rolename = *(paramlst+1);
1261 arg = *(paramlst+2);
1262
1263 if (!jid || !*jid || !rolename || !*rolename) {
1264 scr_LogPrint(LPRINT_NORMAL, "Missing parameter");
1265 free_arg_lst(paramlst);
1266 return;
1267 }
1268
1269 ra.type = type_affil;
1270 ra.val.affil = affil_none;
1271 for (; ra.val.affil < imaffiliation_size; ra.val.affil++)
1272 if (!strcasecmp(rolename, straffil[ra.val.affil]))
1273 break;
1274
1275 if (ra.val.affil < imaffiliation_size)
1276 jb_room_setattrib(roomid, jid, NULL, ra, arg);
1277 else
1278 scr_LogPrint(LPRINT_NORMAL, "Wrong affiliation parameter");
1279
1280 free_arg_lst(paramlst);
1281 }
1282
1283 static void room_role(gpointer bud, char *arg)
1284 {
1285 char **paramlst;
1286 gchar *jid, *rolename;
1287 struct role_affil ra;
1288 const char *roomid = buddy_getjid(bud);
1289
1290 paramlst = split_arg(arg, 3, 1); // jid, new_role, [reason]
1291 jid = *paramlst;
1292 rolename = *(paramlst+1);
1293 arg = *(paramlst+2);
1294
1295 if (!jid || !*jid || !rolename || !*rolename) {
1296 scr_LogPrint(LPRINT_NORMAL, "Missing parameter");
1297 free_arg_lst(paramlst);
1298 return;
1299 }
1300
1301 ra.type = type_role;
1302 ra.val.role = role_none;
1303 for (; ra.val.role < imrole_size; ra.val.role++)
1304 if (!strcasecmp(rolename, strrole[ra.val.role]))
1305 break;
1306
1307 if (ra.val.role < imrole_size)
1308 jb_room_setattrib(roomid, jid, NULL, ra, arg);
1309 else
1310 scr_LogPrint(LPRINT_NORMAL, "Wrong role parameter");
1311
1312 free_arg_lst(paramlst);
1313 }
1314
1315
1249 // The expected argument is a Jabber id 1316 // The expected argument is a Jabber id
1250 static void room_ban(gpointer bud, char *arg) 1317 static void room_ban(gpointer bud, char *arg)
1251 { 1318 {
1252 char **paramlst; 1319 char **paramlst;
1253 gchar *jid; 1320 gchar *jid;
1491 if ((arg = check_room_subcommand(arg, TRUE, NULL)) != NULL) 1558 if ((arg = check_room_subcommand(arg, TRUE, NULL)) != NULL)
1492 room_join(bud, arg); 1559 room_join(bud, arg);
1493 } else if (!strcasecmp(subcmd, "invite")) { 1560 } else if (!strcasecmp(subcmd, "invite")) {
1494 if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL) 1561 if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL)
1495 room_invite(bud, arg); 1562 room_invite(bud, arg);
1563 } else if (!strcasecmp(subcmd, "affil")) {
1564 if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL)
1565 room_affil(bud, arg);
1566 } else if (!strcasecmp(subcmd, "role")) {
1567 if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL)
1568 room_role(bud, arg);
1496 } else if (!strcasecmp(subcmd, "ban")) { 1569 } else if (!strcasecmp(subcmd, "ban")) {
1497 if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL) 1570 if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL)
1498 room_ban(bud, arg); 1571 room_ban(bud, arg);
1499 } else if (!strcasecmp(subcmd, "kick")) { 1572 } else if (!strcasecmp(subcmd, "kick")) {
1500 if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL) 1573 if ((arg = check_room_subcommand(arg, TRUE, bud)) != NULL)