void sighandler(int sig) { switch (sig) { case SIGHUP: gaim_debug_warning("sighandler", "Caught signal %d\n", sig); gaim_connections_disconnect_all(); break; case SIGSEGV: #ifndef DEBUG fprintf(stderr, "Gaim has segfaulted and attempted to dump a core file.\n" "This is a bug in the software and has happened through\n" "no fault of your own.\n\n" "It is possible that this bug is already fixed in CVS.\n" "If you can reproduce the crash, please notify the gaim\n" "maintainers by reporting a bug at\n" GAIM_WEBSITE "bug.php\n\n" "Please make sure to specify what you were doing at the time,\n" "and post the backtrace from the core file. If you do not know\n" "how to get the backtrace, please get instructions at\n" GAIM_WEBSITE "gdb.php. If you need further\n" "assistance, please IM either SeanEgn or LSchiere and\n" "they can help you.\n"); #else fprintf(stderr, "Hi, user. We need to talk.\n" "I think something's gone wrong here. It's probably my fault.\n" "No, really, it's not you... it's me... no no no, I think we get along well\n" "it's just that.... well, I want to see other people. I... what?!? NO! I haven't\n" "been cheating on you!! How many times do you want me to tell you?! And for the\n" "last time, it's just a rash!\n"); /*g_on_error_query (g_get_prgname());*/ #endif abort(); break; case SIGCHLD: clean_pid(); signal(SIGCHLD, sighandler); /* restore signal catching on this one! */ break; default: gaim_debug_warning("sighandler", "Caught signal %d\n", sig); gaim_connections_disconnect_all(); gaim_plugins_unload_all(); if (gtk_main_level()) gtk_main_quit(); exit(0); } }
static void cal_timeout(MsnCmdProc *cmdproc, MsnTransaction *trans) { gaim_debug_warning("msn", "cal_timeout: command %s timed out\n", trans->command); cal_error_helper(trans, MSN_SB_ERROR_UNKNOWN); }
void gaim_presence_set_status_active(GaimPresence *presence, const char *status_id, gboolean active) { GaimStatus *status; g_return_if_fail(presence != NULL); g_return_if_fail(status_id != NULL); status = gaim_presence_get_status(presence, status_id); g_return_if_fail(status != NULL); /* TODO: Should we do the following? */ /* g_return_if_fail(active == status->active); */ if (gaim_status_is_exclusive(status)) { if (!active) { gaim_debug_warning("status", "Attempted to set a non-independent status " "(%s) inactive. Only independent statuses " "can be specifically marked inactive.", status_id); return; } } gaim_status_set_active(status, active); }
static void swboard_error_helper(MsnSwitchBoard *swboard, int reason, const char *passport) { g_return_if_fail(swboard != NULL); gaim_debug_warning("msg", "Error: Unable to call the user %s for reason %i\n", passport ? passport : "(null)", reason); /* TODO: if current_users > 0, this is probably a chat and an invite failed, * we should report that in the chat or something */ if (swboard->current_users == 0) { swboard->error = reason; msn_switchboard_close(swboard); } }
static void gaim_glib_log_handler(const gchar *domain, GLogLevelFlags flags, const gchar *msg, gpointer user_data) { GaimDebugLevel level; char *new_msg = NULL; char *new_domain = NULL; if ((flags & G_LOG_LEVEL_ERROR) == G_LOG_LEVEL_ERROR) level = GAIM_DEBUG_ERROR; else if ((flags & G_LOG_LEVEL_CRITICAL) == G_LOG_LEVEL_CRITICAL) level = GAIM_DEBUG_FATAL; else if ((flags & G_LOG_LEVEL_WARNING) == G_LOG_LEVEL_WARNING) level = GAIM_DEBUG_WARNING; else if ((flags & G_LOG_LEVEL_MESSAGE) == G_LOG_LEVEL_MESSAGE) level = GAIM_DEBUG_INFO; else if ((flags & G_LOG_LEVEL_INFO) == G_LOG_LEVEL_INFO) level = GAIM_DEBUG_INFO; else if ((flags & G_LOG_LEVEL_DEBUG) == G_LOG_LEVEL_DEBUG) level = GAIM_DEBUG_MISC; else { gaim_debug_warning("gtkdebug", "Unknown glib logging level in %d\n", flags); level = GAIM_DEBUG_MISC; /* This will never happen. */ } if (msg != NULL) new_msg = gaim_utf8_try_convert(msg); if (domain != NULL) new_domain = gaim_utf8_try_convert(domain); if (new_msg != NULL) { gaim_debug(level, (new_domain != NULL ? new_domain : "g_log"), "%s\n", new_msg); g_free(new_msg); } if (new_domain != NULL) g_free(new_domain); }
static void cal_error_helper(MsnTransaction *trans, int reason) { MsnSwitchBoard *swboard; const char *passport; char **params; params = g_strsplit(trans->params, " ", 0); passport = params[0]; swboard = trans->data; gaim_debug_warning("msn", "cal_error_helper: command %s failed for reason %i\n",trans->command,reason); swboard_error_helper(swboard, reason, passport); g_strfreev(params); }
static void cal_error(MsnCmdProc *cmdproc, MsnTransaction *trans, int error) { int reason = MSN_SB_ERROR_UNKNOWN; if (error == 215) { gaim_debug_info("msn", "Invited user already in switchboard\n"); return; } else if (error == 217) { reason = MSN_SB_ERROR_USER_OFFLINE; } gaim_debug_warning("msn", "cal_error: command %s gave error %i\n", trans->command, error); cal_error_helper(trans, reason); }
void gaim_mime_part_get_data_decoded(GaimMimePart *part, guchar **data, gsize *len) { const char *enc; g_return_if_fail(part != NULL); g_return_if_fail(data != NULL); g_return_if_fail(len != NULL); g_return_if_fail(part->data != NULL); enc = gaim_mime_part_get_field(part, "content-transfer-encoding"); if(! enc) { *data = (guchar *)g_strdup(part->data->str); *len = part->data->len; } else if(! g_ascii_strcasecmp(enc, "7bit")) { *data = (guchar *)g_strdup(part->data->str); *len = part->data->len; } else if(! g_ascii_strcasecmp(enc, "8bit")) { *data = (guchar *)g_strdup(part->data->str); *len = part->data->len; } else if(! g_ascii_strcasecmp(enc, "base16")) { *data = gaim_base16_decode(part->data->str, len); } else if(! g_ascii_strcasecmp(enc, "base64")) { *data = gaim_base64_decode(part->data->str, len); } else if(! g_ascii_strcasecmp(enc, "quoted-printable")) { *data = gaim_quotedp_decode(part->data->str, len); } else { gaim_debug_warning("mime", "gaim_mime_part_get_data_decoded:" " unknown encoding '%s'\n", enc); *data = NULL; *len = 0; } }
static void open_button_cb(GtkButton *button, GaimGtkXferDialog *dialog) { #ifdef _WIN32 /* Only supported in Win32 right now */ int code; if (G_WIN32_HAVE_WIDECHAR_API ()) { wchar_t *wc_filename = g_utf8_to_utf16( gaim_xfer_get_local_filename( dialog->selected_xfer), -1, NULL, NULL, NULL); code = (int) ShellExecuteW(NULL, NULL, wc_filename, NULL, NULL, SW_SHOW); g_free(wc_filename); } else { char *l_filename = g_locale_from_utf8( gaim_xfer_get_local_filename( dialog->selected_xfer), -1, NULL, NULL, NULL); code = (int) ShellExecuteA(NULL, NULL, l_filename, NULL, NULL, SW_SHOW); g_free(l_filename); } if (code == SE_ERR_ASSOCINCOMPLETE || code == SE_ERR_NOASSOC) { gaim_notify_error(NULL, NULL, _("There is no application configured to open this type of file."), NULL); } else if (code < 32) { gaim_notify_error(NULL, NULL, _("An error occurred while opening the file."), NULL); gaim_debug_warning("ft", "filename: %s; code: %d\n", gaim_xfer_get_local_filename(dialog->selected_xfer), code); } #endif }
static gboolean plugin_load(GaimPlugin *plugin) { GaimBuddyList *list = gaim_get_blist(); void *conn_handle = gaim_connections_get_handle(); if (!check_timeout(NULL)) { gaim_debug_warning("mailchk", "Could not read $MAIL or /var/spool/mail/$USER"); return FALSE; } if (list && GAIM_IS_GTK_BLIST(list) && GAIM_GTK_BLIST(list)->vbox) timer = g_timeout_add(2000, check_timeout, NULL); gaim_signal_connect(conn_handle, "signed-on", plugin, GAIM_CALLBACK(signon_cb), NULL); gaim_signal_connect(conn_handle, "signed-off", plugin, GAIM_CALLBACK(signoff_cb), NULL); return TRUE; }
int yahoo_packet_send(struct yahoo_packet *pkt, struct yahoo_data *yd) { size_t len; int ret; guchar *data; if (yd->fd < 0) return -1; len = yahoo_packet_build(pkt, 0, yd->wm, yd->jp, &data); yahoo_packet_dump(data, len); if (yd->txhandler == -1) ret = write(yd->fd, data, len); else { ret = -1; errno = EAGAIN; } if (ret < 0 && errno == EAGAIN) ret = 0; else if (ret <= 0) { gaim_debug_warning("yahoo", "Only wrote %d of %d bytes!", ret, len); g_free(data); return ret; } if (ret < len) { if (yd->txhandler == -1) yd->txhandler = gaim_input_add(yd->fd, GAIM_INPUT_WRITE, yahoo_packet_send_can_write, yd); gaim_circ_buffer_append(yd->txbuf, data + ret, len - ret); } g_free(data); return ret; }
static void jabber_si_xfer_bytestreams_send_connected_cb(gpointer data, gint source, GaimInputCondition cond) { GaimXfer *xfer = data; int acceptfd; gaim_debug_info("jabber", "in jabber_si_xfer_bytestreams_send_connected_cb\n"); acceptfd = accept(source, NULL, 0); if(acceptfd == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)) return; else if(acceptfd == -1) { gaim_debug_warning("jabber", "accept: %s\n", strerror(errno)); return; } gaim_input_remove(xfer->watcher); close(source); xfer->watcher = gaim_input_add(acceptfd, GAIM_INPUT_READ, jabber_si_xfer_bytestreams_send_read_cb, xfer); }
static void irc_dccsend_send_connected(gpointer data, int source, GaimInputCondition cond) { GaimXfer *xfer = (GaimXfer *) data; struct irc_xfer_send_data *xd = xfer->data; int conn; conn = accept(xd->fd, NULL, 0); if (conn == -1) { /* Accepting the connection failed. This could just be related * to the nonblocking nature of the listening socket, so we'll * just try again next time */ /* Let's print an error message anyway */ gaim_debug_warning("irc", "accept: %s\n", strerror(errno)); return; } gaim_input_remove(xfer->watcher); xfer->watcher = 0; close(xd->fd); xd->fd = -1; xd->inpa = gaim_input_add(conn, GAIM_INPUT_READ, irc_dccsend_send_read, xfer); /* Start the transfer */ gaim_xfer_start(xfer, conn, NULL, 0); }
gboolean gaym_privacy_check(GaimConnection * gc, const char *nick) { /** * returns TRUE if allowed through, FALSE otherwise */ GSList *list; gboolean permitted = FALSE; switch (gc->account->perm_deny) { case 0: gaim_debug_warning("gaym", "Privacy setting was 0. If you can " "reproduce this, please file a bug report.\n"); permitted = TRUE; break; case GAIM_PRIVACY_ALLOW_ALL: permitted = TRUE; break; case GAIM_PRIVACY_DENY_ALL: gaim_debug_info("gaym", "%s blocked data received from %s (GAIM_PRIVACY_DENY_ALL)\n", gc->account->username, nick); break; case GAIM_PRIVACY_ALLOW_USERS: for (list = gc->account->permit; list != NULL; list = list->next) { if (!gaim_utf8_strcasecmp (nick, gaim_normalize(gc->account, (char *) list->data))) { permitted = TRUE; gaim_debug_info("gaym", "%s allowed data received from %s (GAIM_PRIVACY_ALLOW_USERS)\n", gc->account->username, nick); break; } } break; case GAIM_PRIVACY_DENY_USERS: /* seeing we're letting everyone through, except the deny list */ permitted = TRUE; for (list = gc->account->deny; list != NULL; list = list->next) { if (!gaim_utf8_strcasecmp (nick, gaim_normalize(gc->account, (char *) list->data))) { permitted = FALSE; gaim_debug_info("gaym", "%s blocked data received from %s (GAIM_PRIVACY_DENY_USERS)\n", gc->account->username, nick); break; } } break; case GAIM_PRIVACY_ALLOW_BUDDYLIST: if (gaim_find_buddy(gc->account, nick) != NULL) { permitted = TRUE; } else { gaim_debug_info("gaym", "%s blocked data received from %s (GAIM_PRIVACY_ALLOW_BUDDYLIST)\n", gc->account->username, nick); } break; default: gaim_debug_warning("gaym", "Privacy setting was unknown. If you can " "reproduce this, please file a bug report.\n"); permitted = FALSE; break; } /** * don't block/ignore self */ if (!gaim_utf8_strcasecmp(gc->account->username, nick)) { permitted = TRUE; gaim_debug_info("gaym", "declining to block/ignore self\n"); return permitted; } return permitted; }
static void msn_switchboard_add_user(MsnSwitchBoard *swboard, const char *user) { MsnCmdProc *cmdproc; GaimAccount *account; g_return_if_fail(swboard != NULL); cmdproc = swboard->cmdproc; account = cmdproc->session->account; swboard->users = g_list_prepend(swboard->users, g_strdup(user)); swboard->current_users++; swboard->empty = FALSE; #ifdef MSN_DEBUG_CHAT gaim_debug_info("msn", "user=[%s], total=%d\n", user, swboard->current_users); #endif if (!(swboard->flag & MSN_SB_FLAG_IM) && (swboard->conv != NULL)) { /* This is a helper switchboard. */ gaim_debug_error("msn", "switchboard_add_user: conv != NULL\n"); return; } if ((swboard->conv != NULL) && (gaim_conversation_get_type(swboard->conv) == GAIM_CONV_TYPE_CHAT)) { gaim_conv_chat_add_user(GAIM_CONV_CHAT(swboard->conv), user, NULL, GAIM_CBFLAGS_NONE, TRUE); } else if (swboard->current_users > 1 || swboard->total_users > 1) { if (swboard->conv == NULL || gaim_conversation_get_type(swboard->conv) != GAIM_CONV_TYPE_CHAT) { GList *l; #ifdef MSN_DEBUG_CHAT gaim_debug_info("msn", "[chat] Switching to chat.\n"); #endif #if 0 /* this is bad - it causes msn_switchboard_close to be called on the * switchboard we're in the middle of using :( */ if (swboard->conv != NULL) gaim_conversation_destroy(swboard->conv); #endif swboard->chat_id = cmdproc->session->conv_seq++; swboard->flag |= MSN_SB_FLAG_IM; swboard->conv = serv_got_joined_chat(account->gc, swboard->chat_id, "MSN Chat"); for (l = swboard->users; l != NULL; l = l->next) { const char *tmp_user; tmp_user = l->data; #ifdef MSN_DEBUG_CHAT gaim_debug_info("msn", "[chat] Adding [%s].\n", tmp_user); #endif gaim_conv_chat_add_user(GAIM_CONV_CHAT(swboard->conv), tmp_user, NULL, GAIM_CBFLAGS_NONE, TRUE); } #ifdef MSN_DEBUG_CHAT gaim_debug_info("msn", "[chat] We add ourselves.\n"); #endif gaim_conv_chat_add_user(GAIM_CONV_CHAT(swboard->conv), gaim_account_get_username(account), NULL, GAIM_CBFLAGS_NONE, TRUE); g_free(swboard->im_user); swboard->im_user = NULL; } } else if (swboard->conv == NULL) { swboard->conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, user, account); } else { gaim_debug_warning("msn", "switchboard_add_user: This should not happen!\n"); } }
void gaim_status_set_active_with_attrs_list(GaimStatus *status, gboolean active, const GList *attrs) { gboolean changed = FALSE; const GList *l; GList *specified_attr_ids = NULL; GaimStatusType *status_type; g_return_if_fail(status != NULL); if (!active && gaim_status_is_exclusive(status)) { gaim_debug_error("status", "Cannot deactivate an exclusive status (%s).\n", gaim_status_get_id(status)); return; } if (status->active != active) { changed = TRUE; } status->active = active; /* Set any attributes */ l = attrs; while (l != NULL) { const gchar *id; GaimValue *value; id = l->data; l = l->next; value = gaim_status_get_attr_value(status, id); if (value == NULL) { gaim_debug_warning("status", "The attribute \"%s\" on the status \"%s\" is " "not supported.\n", id, status->type->name); /* Skip over the data and move on to the next attribute */ l = l->next; continue; } specified_attr_ids = g_list_prepend(specified_attr_ids, (gpointer)id); if (value->type == GAIM_TYPE_STRING) { const gchar *string_data = l->data; l = l->next; if (((string_data == NULL) && (value->data.string_data == NULL)) || ((string_data != NULL) && (value->data.string_data != NULL) && !strcmp(string_data, value->data.string_data))) { continue; } gaim_status_set_attr_string(status, id, string_data); changed = TRUE; } else if (value->type == GAIM_TYPE_INT) { int int_data = GPOINTER_TO_INT(l->data); l = l->next; if (int_data == value->data.int_data) continue; gaim_status_set_attr_int(status, id, int_data); changed = TRUE; } else if (value->type == GAIM_TYPE_BOOLEAN) { gboolean boolean_data = GPOINTER_TO_INT(l->data); l = l->next; if (boolean_data == value->data.boolean_data) continue; gaim_status_set_attr_boolean(status, id, boolean_data); changed = TRUE; } else { /* We don't know what the data is--skip over it */ l = l->next; } } /* Reset any unspecified attributes to their default value */ status_type = gaim_status_get_type(status); l = gaim_status_type_get_attrs(status_type); while (l != NULL) { GaimStatusAttr *attr; attr = l->data; if (!g_list_find_custom(specified_attr_ids, attr->id, (GCompareFunc)strcmp)) { GaimValue *default_value; default_value = gaim_status_attr_get_value(attr); if (default_value->type == GAIM_TYPE_STRING) gaim_status_set_attr_string(status, attr->id, gaim_value_get_string(default_value)); else if (default_value->type == GAIM_TYPE_INT) gaim_status_set_attr_int(status, attr->id, gaim_value_get_int(default_value)); else if (default_value->type == GAIM_TYPE_BOOLEAN) gaim_status_set_attr_boolean(status, attr->id, gaim_value_get_boolean(default_value)); changed = TRUE; } l = l->next; } g_list_free(specified_attr_ids); if (!changed) return; status_has_changed(status); }