Changes in root_commands.c [9f03c47:ad9ac5d]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
root_commands.c
r9f03c47 rad9ac5d 143 143 } 144 144 145 status = auth_check_pass(irc, irc->user->nick, password); 146 if (load && (status == STORAGE_OK)) { 145 if (load) { 147 146 status = storage_load(irc, password); 147 } else { 148 status = storage_check_pass(irc->user->nick, password); 148 149 } 149 150 … … 158 159 irc_rootmsg(irc, "Password accepted%s", 159 160 load ? ", settings and accounts loaded" : ""); 161 irc_setpass(irc, password); 160 162 irc->status |= USTATUS_IDENTIFIED; 161 163 irc_umode_set(irc, "+R", 1); … … 266 268 storage_status_t status; 267 269 268 status = auth_check_pass(irc, irc->user->nick, cmd[1]); 269 if (status == STORAGE_OK) { 270 status = storage_remove(irc->user->nick); 271 } 272 270 status = storage_remove(irc->user->nick, cmd[1]); 273 271 switch (status) { 274 272 case STORAGE_NO_SUCH_USER: … … 342 340 int st; 343 341 344 if (s && s->flags & SET_LOCKED) {345 irc_rootmsg(irc, "This setting can not be changed");346 return 0;347 }348 342 if (s && checkflags && checkflags(irc, s) == 0) { 349 343 return 0; … … 394 388 irc_rootmsg(irc, "This setting can only be changed when the account is %s-line", "on"); 395 389 return 0; 396 } else if (a->flags & ACC_FLAG_LOCKED && s && s->flags & ACC_SET_LOCKABLE) {397 irc_rootmsg(irc, "This setting can not be changed for locked accounts");398 return 0;399 390 } 400 391 … … 418 409 419 410 MIN_ARGS(3); 420 421 if (!global.conf->allow_account_add) {422 irc_rootmsg(irc, "This server does not allow adding new accounts");423 return;424 }425 411 426 412 if (cmd[4] == NULL) { … … 470 456 irc_rootmsg(irc, "No need to enter a password for this " 471 457 "account since it's using OAuth"); 472 } else if (prpl->options & PRPL_OPT_NO_PASSWORD) {473 *a->pass = '\0';474 } else if (prpl->options & PRPL_OPT_PASSWORD_OPTIONAL) {475 *a->pass = '\0';476 irc_rootmsg(irc, "Passwords are optional for this account. "477 "If you wish to enter the password with /OPER, do "478 "account %s set -del password", a->tag);479 458 } else { 480 459 irc_rootmsg(irc, "You can now use the /OPER command to " … … 486 465 } 487 466 } 488 } else if (prpl->options & PRPL_OPT_NO_PASSWORD) {489 irc_rootmsg(irc, "Note: this account doesn't use password for login");490 467 } 491 468 … … 570 547 571 548 if (len >= 1 && g_strncasecmp(cmd[2], "del", len) == 0) { 572 if (a->flags & ACC_FLAG_LOCKED) { 573 irc_rootmsg(irc, "Account is locked, can't delete"); 574 } 575 else if (a->ic) { 549 if (a->ic) { 576 550 irc_rootmsg(irc, "Account is still logged in, can't delete"); 577 551 } else { … … 1116 1090 } 1117 1091 1118 static gint prplcmp(gconstpointer a, gconstpointer b)1119 {1120 const struct prpl *pa = a;1121 const struct prpl *pb = b;1122 1123 return g_strcasecmp(pa->name, pb->name);1124 }1125 1126 static void prplstr(GList *prpls, GString *gstr)1127 {1128 const char *last = NULL;1129 GList *l;1130 struct prpl *p;1131 1132 prpls = g_list_copy(prpls);1133 prpls = g_list_sort(prpls, prplcmp);1134 1135 for (l = prpls; l; l = l->next) {1136 p = l->data;1137 1138 if (last && g_strcasecmp(p->name, last) == 0) {1139 /* Ignore duplicates (mainly for libpurple) */1140 continue;1141 }1142 1143 if (gstr->len != 0) {1144 g_string_append(gstr, ", ");1145 }1146 1147 g_string_append(gstr, p->name);1148 last = p->name;1149 }1150 1151 g_list_free(prpls);1152 }1153 1154 static void cmd_plugins(irc_t *irc, char **cmd)1155 {1156 GList *prpls;1157 GString *gstr;1158 1159 #ifdef WITH_PLUGINS1160 GList *l;1161 struct plugin_info *info;1162 1163 for (l = get_plugins(); l; l = l->next) {1164 info = l->data;1165 irc_rootmsg(irc, "%s:", info->name);1166 irc_rootmsg(irc, " Version: %s", info->version);1167 1168 if (info->description) {1169 irc_rootmsg(irc, " Description: %s", info->description);1170 }1171 1172 if (info->author) {1173 irc_rootmsg(irc, " Author: %s", info->author);1174 }1175 1176 if (info->url) {1177 irc_rootmsg(irc, " URL: %s", info->url);1178 }1179 1180 irc_rootmsg(irc, "");1181 }1182 #endif1183 1184 gstr = g_string_new(NULL);1185 prpls = get_protocols();1186 1187 if (prpls) {1188 prplstr(prpls, gstr);1189 irc_rootmsg(irc, "Enabled Protocols: %s", gstr->str);1190 g_string_truncate(gstr, 0);1191 }1192 1193 prpls = get_protocols_disabled();1194 1195 if (prpls) {1196 prplstr(prpls, gstr);1197 irc_rootmsg(irc, "Disabled Protocols: %s", gstr->str);1198 }1199 1200 g_string_free(gstr, TRUE);1201 }1202 1203 1092 static void cmd_qlist(irc_t *irc, char **cmd) 1204 1093 { … … 1227 1116 1228 1117 if (g_strcasecmp(cmd[1], "add") == 0) { 1229 bee_chat_info_t *ci; 1230 char *channel, *room, *s; 1118 char *channel, *s; 1231 1119 struct irc_channel *ic; 1232 guint i;1233 1120 1234 1121 MIN_ARGS(3); … … 1242 1129 } 1243 1130 1244 if (cmd[3][0] == '!') {1245 if (!acc->ic || !(acc->ic->flags & OPT_LOGGED_IN)) {1246 irc_rootmsg(irc, "Not logged in to account.");1247 return;1248 } else if (!acc->prpl->chat_list) {1249 irc_rootmsg(irc, "Listing chatrooms not supported on that account.");1250 return;1251 }1252 1253 i = g_ascii_strtoull(cmd[3] + 1, NULL, 10);1254 ci = g_slist_nth_data(acc->ic->chatlist, i - 1);1255 1256 if (ci == NULL) {1257 irc_rootmsg(irc, "Invalid chatroom index");1258 return;1259 }1260 1261 room = ci->title;1262 } else {1263 room = cmd[3];1264 }1265 1266 1131 if (cmd[4] == NULL) { 1267 channel = g_strdup( room);1132 channel = g_strdup(cmd[3]); 1268 1133 if ((s = strchr(channel, '@'))) { 1269 1134 *s = 0; … … 1285 1150 set_setstr(&ic->set, "chat_type", "room") && 1286 1151 set_setstr(&ic->set, "account", cmd[2]) && 1287 set_setstr(&ic->set, "room", room)) {1152 set_setstr(&ic->set, "room", cmd[3])) { 1288 1153 irc_rootmsg(irc, "Chatroom successfully added."); 1289 1154 } else { … … 1295 1160 } 1296 1161 g_free(channel); 1297 } else if (g_strcasecmp(cmd[1], "list") == 0) {1298 MIN_ARGS(2);1299 1300 if (!(acc = account_get(irc->b, cmd[2]))) {1301 irc_rootmsg(irc, "Invalid account");1302 return;1303 } else if (!acc->ic || !(acc->ic->flags & OPT_LOGGED_IN)) {1304 irc_rootmsg(irc, "Not logged in to account.");1305 return;1306 } else if (!acc->prpl->chat_list) {1307 irc_rootmsg(irc, "Listing chatrooms not supported on that account.");1308 return;1309 }1310 1311 acc->prpl->chat_list(acc->ic, cmd[3]);1312 1162 } else if (g_strcasecmp(cmd[1], "with") == 0) { 1313 1163 irc_user_t *iu; … … 1324 1174 irc_rootmsg(irc, "Can't open a groupchat with %s.", cmd[2]); 1325 1175 } 1326 } else if (g_strcasecmp(cmd[1], "set") == 0 || 1176 } else if (g_strcasecmp(cmd[1], "list") == 0 || 1177 g_strcasecmp(cmd[1], "set") == 0 || 1327 1178 g_strcasecmp(cmd[1], "del") == 0) { 1328 1179 irc_rootmsg(irc, … … 1334 1185 cmd[1]); 1335 1186 } 1336 }1337 1338 /* some arbitrary numbers */1339 #define CHAT_TITLE_LEN_MIN 201340 #define CHAT_TITLE_LEN_MAX 1001341 1342 void cmd_chat_list_finish(struct im_connection *ic)1343 {1344 account_t *acc = ic->acc;1345 bee_chat_info_t *ci;1346 char *hformat, *iformat, *topic, *padded;1347 GSList *l;1348 guint i = 0;1349 long title_len, new_len;1350 irc_t *irc = ic->bee->ui_data;1351 1352 if (ic->chatlist == NULL) {1353 irc_rootmsg(irc, "No existing chatrooms");1354 return;1355 }1356 1357 /* find a reasonable width for the table */1358 title_len = CHAT_TITLE_LEN_MIN;1359 1360 for (l = ic->chatlist; l; l = l->next) {1361 ci = l->data;1362 new_len = g_utf8_strlen(ci->title, -1);1363 1364 if (new_len >= CHAT_TITLE_LEN_MAX) {1365 title_len = CHAT_TITLE_LEN_MAX;1366 break;1367 } else if (title_len < new_len) {1368 title_len = new_len;1369 }1370 }1371 1372 if (strchr(irc->umode, 'b') != NULL) {1373 hformat = "%s\t%s\t%s";1374 iformat = "%u\t%s\t%s";1375 } else {1376 hformat = "%s %s %s";1377 iformat = "%5u %s %s";1378 }1379 1380 padded = str_pad_and_truncate("Title", title_len, NULL);1381 irc_rootmsg(irc, hformat, "Index", padded, "Topic");1382 g_free(padded);1383 1384 for (l = ic->chatlist; l; l = l->next) {1385 ci = l->data;1386 topic = ci->topic ? ci->topic : "";1387 1388 padded = str_pad_and_truncate(ci->title, title_len, "[...]");1389 irc_rootmsg(irc, iformat, ++i, padded, topic);1390 g_free(padded);1391 }1392 1393 irc_rootmsg(irc, "%u %s chatrooms", i, acc->tag);1394 1187 } 1395 1188 … … 1445 1238 { 1446 1239 GSList *files = irc->file_transfers; 1447 GSList *next;1448 1240 1449 1241 enum { LIST, REJECT, CANCEL }; … … 1463 1255 } 1464 1256 1465 for (; files; files = next) { 1466 next = files->next; 1257 for (; files; files = g_slist_next(files)) { 1467 1258 file_transfer_t *file = files->data; 1468 1259 … … 1548 1339 { "nick", 1, cmd_nick, 0 }, 1549 1340 { "no", 0, cmd_yesno, 0 }, 1550 { "plugins", 0, cmd_plugins, 0 },1551 1341 { "qlist", 0, cmd_qlist, 0 }, 1552 1342 { "register", 0, cmd_register, 0 },
Note: See TracChangeset
for help on using the changeset viewer.