Changeset 29ff5c2 for irc_send.c
- Timestamp:
- 2015-11-21T00:01:50Z (8 years ago)
- Parents:
- e4f08bf (diff), 8fdeaa5 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
irc_send.c
re4f08bf r29ff5c2 172 172 irc_t *irc = ic->irc; 173 173 174 irc_write(irc, ":%s!%s@%s JOIN :%s", iu->nick, iu->user, iu->host, ic->name); 174 if (irc->caps & CAP_EXTENDED_JOIN) { 175 irc_write(irc, ":%s!%s@%s JOIN %s * :%s", iu->nick, iu->user, iu->host, ic->name, iu->fullname); 176 } else { 177 irc_write(irc, ":%s!%s@%s JOIN :%s", iu->nick, iu->user, iu->host, ic->name); 178 } 175 179 176 180 if (iu == irc->user) { … … 214 218 } 215 219 216 if (icu->flags & IRC_CHANNEL_USER_OP) { 217 strcat(namelist, "@"); 218 } else if (icu->flags & IRC_CHANNEL_USER_HALFOP) { 219 strcat(namelist, "%"); 220 } else if (icu->flags & IRC_CHANNEL_USER_VOICE) { 221 strcat(namelist, "+"); 222 } 220 namelist[strlen(namelist) + 1] = '\0'; 221 namelist[strlen(namelist)] = irc_channel_user_get_prefix(icu); 223 222 224 223 strcat(namelist, iu->nick); … … 249 248 } 250 249 250 /* msg1 and msg2 are output parameters. If msg2 is non-null, msg1 is guaranteed to be non-null too. 251 The idea is to defer the formatting of "$msg1 ($msg2)" to later calls to avoid a g_strdup_printf() here. */ 252 static void get_status_message(bee_user_t *bu, char **msg1, char **msg2) 253 { 254 *msg1 = NULL; 255 *msg2 = NULL; 256 257 if (!(bu->flags & BEE_USER_ONLINE)) { 258 *msg1 = "User is offline"; 259 260 } else if ((bu->status && *bu->status) || 261 (bu->status_msg && *bu->status_msg)) { 262 263 if (bu->status && bu->status_msg) { 264 *msg1 = bu->status; 265 *msg2 = bu->status_msg; 266 } else { 267 *msg1 = bu->status ? : bu->status_msg; 268 } 269 } 270 271 if (*msg1 && !**msg1) { 272 *msg1 = (bu->flags & BEE_USER_AWAY) ? "Away" : NULL; 273 } 274 } 275 251 276 void irc_send_whois(irc_user_t *iu) 252 277 { … … 258 283 if (iu->bu) { 259 284 bee_user_t *bu = iu->bu; 285 char *msg1, *msg2; 286 int num; 260 287 261 288 irc_send_num(irc, 312, "%s %s.%s :%s network", iu->nick, bu->ic->acc->user, … … 263 290 bu->ic->acc->prpl->name); 264 291 265 if ((bu->status && *bu->status) || 266 (bu->status_msg && *bu->status_msg)) { 267 int num = bu->flags & BEE_USER_AWAY ? 301 : 320; 268 269 if (bu->status && bu->status_msg) { 270 irc_send_num(irc, num, "%s :%s (%s)", iu->nick, bu->status, bu->status_msg); 271 } else { 272 irc_send_num(irc, num, "%s :%s", iu->nick, bu->status ? : bu->status_msg); 273 } 274 } else if (!(bu->flags & BEE_USER_ONLINE)) { 275 irc_send_num(irc, 301, "%s :%s", iu->nick, "User is offline"); 292 num = (bu->flags & BEE_USER_AWAY || !(bu->flags & BEE_USER_ONLINE)) ? 301 : 320; 293 294 get_status_message(bu, &msg1, &msg2); 295 296 if (msg1 && msg2) { 297 irc_send_num(irc, num, "%s :%s (%s)", iu->nick, msg1, msg2); 298 } else if (msg1) { 299 irc_send_num(irc, num, "%s :%s", iu->nick, msg1); 276 300 } 277 301 … … 294 318 295 319 while (l) { 296 irc_user_t *iu = l->data; 320 irc_user_t *iu; 321 322 /* Null terminated string with three chars, respectively: 323 * { <H|G>, <@|%|+|\0>, \0 } */ 324 char status_prefix[3] = {0}; 325 297 326 if (is_channel) { 298 iu = ((irc_channel_user_t *) iu)->iu; 299 } 300 /* TODO(wilmer): Restore away/channel information here */ 301 irc_send_num(irc, 352, "%s %s %s %s %s %c :0 %s", 327 irc_channel_user_t *icu = l->data; 328 status_prefix[1] = irc_channel_user_get_prefix(icu); 329 iu = icu->iu; 330 } else { 331 iu = l->data; 332 } 333 334 /* rfc1459 doesn't mention this: G means gone, H means here */ 335 status_prefix[0] = iu->flags & IRC_USER_AWAY ? 'G' : 'H'; 336 337 irc_send_num(irc, 352, "%s %s %s %s %s %s :0 %s", 302 338 is_channel ? channel : "*", iu->user, iu->host, irc->root->host, 303 iu->nick, iu->flags & IRC_USER_AWAY ? 'G' : 'H', 304 iu->fullname); 339 iu->nick, status_prefix, iu->fullname); 305 340 l = l->next; 306 341 } … … 428 463 iu->nick, iu->user, iu->host, irc->user->nick, ic->name); 429 464 } 465 466 void irc_send_cap(irc_t *irc, char *subcommand, char *body) 467 { 468 char *nick = irc->user->nick ? : "*"; 469 470 irc_write(irc, ":%s CAP %s %s :%s", irc->root->host, nick, subcommand, body); 471 } 472 473 void irc_send_away_notify(irc_user_t *iu) 474 { 475 bee_user_t *bu = iu->bu; 476 477 if (!bu) { 478 return; 479 } 480 481 if (bu->flags & BEE_USER_AWAY || !(bu->flags & BEE_USER_ONLINE)) { 482 char *msg1, *msg2; 483 484 get_status_message(bu, &msg1, &msg2); 485 486 if (msg2) { 487 irc_write(iu->irc, ":%s!%s@%s AWAY :%s (%s)", iu->nick, iu->user, iu->host, msg1, msg2); 488 } else { 489 irc_write(iu->irc, ":%s!%s@%s AWAY :%s", iu->nick, iu->user, iu->host, msg1); 490 } 491 } else { 492 irc_write(iu->irc, ":%s!%s@%s AWAY", iu->nick, iu->user, iu->host); 493 } 494 } 495
Note: See TracChangeset
for help on using the changeset viewer.