/* Determine whether the specified dll contains the specified procedure. If so, load it (if not already loaded). */ FARPROC wgaim_find_and_loadproc( char* dllname, char* procedure ) { HMODULE hmod; int did_load=0; FARPROC proc = 0; if(!(hmod=GetModuleHandle(dllname))) { gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "%s not found. Loading it..\n", dllname); if(!(hmod = LoadLibrary(dllname))) { gaim_debug(GAIM_DEBUG_ERROR, "wgaim", "Could not load: %s\n", dllname); return NULL; } else did_load = 1; } if((proc=GetProcAddress(hmod, procedure))) { gaim_debug(GAIM_DEBUG_INFO, "wgaim", "This version of %s contains %s\n", dllname, procedure); return proc; } else { gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "Function %s not found in dll %s\n", procedure, dllname); if(did_load) { /* unload dll */ FreeLibrary(hmod); } return NULL; } }
gint qq_proxy_socks5(struct PHB *phb, struct sockaddr *addr, socklen_t addrlen) { gint fd; gaim_debug(GAIM_DEBUG_INFO, "QQ", "Connecting to %s:%d via %s:%d using SOCKS5\n", phb->host, phb->port, gaim_proxy_info_get_host(phb->gpi), gaim_proxy_info_get_port(phb->gpi)); if ((fd = socket(addr->sa_family, SOCK_STREAM, 0)) < 0) return -1; gaim_debug(GAIM_DEBUG_INFO, "QQ", "proxy_sock5 return fd=%d\n", fd); fcntl(fd, F_SETFL, O_NONBLOCK); if (connect(fd, addr, addrlen) < 0) { if ((errno == EINPROGRESS) || (errno == EINTR)) { gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Connect in asynchronous mode.\n"); phb->inpa = gaim_input_add(fd, GAIM_INPUT_WRITE, _qq_s5_canwrite, phb); } else { close(fd); return -1; } } else { gaim_debug(GAIM_DEBUG_MISC, "QQ", "Connect in blocking mode.\n"); fcntl(fd, F_SETFL, 0); _qq_s5_canwrite(phb, fd, GAIM_INPUT_WRITE); } return fd; }
static int halt_flash_filter(GtkWidget *widget, GdkEventFocus *event, gpointer data) { if(MyFlashWindowEx) { HWND hWnd = data; FLASHWINFO info; if(!IsWindow(hWnd)) return 0; memset(&info, 0, sizeof(FLASHWINFO)); info.cbSize = sizeof(FLASHWINFO); info.hwnd = hWnd; info.dwFlags = FLASHW_STOP; info.dwTimeout = 0; MyFlashWindowEx(&info); } else { WGAIM_FLASH_INFO *finfo = data; /* Stop flashing and remove filter */ gaim_debug(GAIM_DEBUG_INFO, "wgaim", "Removing timeout\n"); gaim_timeout_remove(finfo->t_handle); gaim_debug(GAIM_DEBUG_INFO, "wgaim", "Disconnecting signal handler\n"); g_signal_handler_disconnect(G_OBJECT(widget),finfo->sig_handler); gaim_debug(GAIM_DEBUG_INFO, "wgaim", "done\n"); g_free(finfo); } return 0; }
static void sippy_login(GaimAccount *account) { char *sipAccountURI = NULL; GaimConnection *gc = gaim_account_get_connection(account); if (gaim_connection_get_state(gc) == GAIM_CONNECTED) { gaim_debug(GAIM_DEBUG_INFO,"sippy","Somebody's trying to login to something that's already connected - ignoring the request\n"); return; } /* * Do a safety check on the account name */ if (isAccountNameUnsafe(account->username)) { gaim_connection_error(gc, _("Login not attempted - The account name is unacceptable")); g_free(sipAccountURI); return; } sipAccountURI = buildSIPURI(account->username); struct simple_connection_cache *sc_cache; if (gc->proto_data == NULL) { gaim_debug(GAIM_DEBUG_INFO,"sippy","Creating new simple cache\n"); sc_cache = gc->proto_data = g_new0(struct simple_connection_cache,1); }
static void gaym_weblogin_step2(gpointer data, const char* text, size_t len) { struct gaym_conn *gaym=(struct gaym_conn*)data; if(GAIM_CONNECTION_IS_VALID(gaym->session->account->gc)) { //The second step is to do the actual login. //We connect to misc/dologin.html, using cookies set from step 1 //And add a few more cookie values. char url[1024]; char* buf = g_strdup_printf(_("Signon: %s"), gaym->session->account->username); gaim_connection_update_progress(gaym->session->account->gc, buf, 3, 6); gaim_debug(GAIM_DEBUG_MISC, "gaym", "From step one, got cookies: %s\n", (gaym->session->cookies)); snprintf(url,1024,"http://www.gay.com/misc/dologin.html?__login_haveForm=1&__login_save=1&__login_member=%s&redir=%%2Findex.html&__login_basepage=%%2Fmisc%%2Fdologin.html&__login_password=%s", gaym->session->username, gaym->session->password); gaim_debug(GAIM_DEBUG_MISC, "gaym", "In step 2, trying: %s\n", url); gaym->session->hasFormData=TRUE; gaim_session_fetch(url, FALSE, NULL, FALSE,gaym_weblogin_step3, gaym, gaym->session); } else g_free(gaym->session); }
/* this should be called upon signin, even when we did not open group chat window */ void qq_group_init(GaimConnection *gc) { gint i; GaimAccount *account; GaimChat *chat; GaimGroup *gaim_group; GaimBlistNode *node; qq_group *group; account = gaim_connection_get_account(gc); gaim_group = gaim_find_group(GAIM_GROUP_QQ_QUN); if (gaim_group == NULL) { gaim_debug(GAIM_DEBUG_INFO, "QQ", "We have no QQ Qun\n"); return; } i = 0; for (node = ((GaimBlistNode *) gaim_group)->child; node != NULL; node = node->next) if (GAIM_BLIST_NODE_IS_CHAT(node)) { /* got one */ chat = (GaimChat *) node; if (account != chat->account) continue; /* very important here ! */ group = qq_group_from_hashtable(gc, chat->components); if (group != NULL) { i++; qq_send_cmd_group_get_group_info(gc, group); /* get group info and members */ } } gaim_debug(GAIM_DEBUG_INFO, "QQ", "Load %d QQ Qun configurations\n", i); }
static void _qq_s5_canwrite(gpointer data, gint source, GaimInputCondition cond) { unsigned char buf[512]; int i; struct PHB *phb = data; unsigned int len; int error = ETIMEDOUT; gaim_debug(GAIM_DEBUG_INFO, "socks5 proxy", "Connected.\n"); if (phb->inpa > 0) gaim_input_remove(phb->inpa); len = sizeof(error); if (getsockopt(source, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { gaim_debug(GAIM_DEBUG_INFO, "getsockopt", "%s\n", strerror(errno)); close(source); if (phb->account == NULL || gaim_account_get_connection(phb->account) != NULL) { phb->func(phb->data, -1, _("Unable to connect")); } g_free(phb->host); g_free(phb); return; } fcntl(source, F_SETFL, 0); i = 0; buf[0] = 0x05; /* SOCKS version 5 */ if (gaim_proxy_info_get_username(phb->gpi) != NULL) { buf[1] = 0x02; /* two methods */ buf[2] = 0x00; /* no authentication */ buf[3] = 0x02; /* username/password authentication */ i = 4; } else { buf[1] = 0x01; buf[2] = 0x00; i = 3; } if (write(source, buf, i) < i) { gaim_debug(GAIM_DEBUG_INFO, "write", "%s\n", strerror(errno)); gaim_debug(GAIM_DEBUG_ERROR, "socks5 proxy", "Unable to write\n"); close(source); if (phb->account == NULL || gaim_account_get_connection(phb->account) != NULL) { phb->func(phb->data, -1, _("Unable to connect")); } g_free(phb->host); g_free(phb); return; } phb->inpa = gaim_input_add(source, GAIM_INPUT_READ, _qq_s5_canread, phb); }
static void sippy_logout(GaimConnection *gc) { if (!gaginitialized) {return;} gaim_debug(GAIM_DEBUG_INFO,"sippy","sending LOGOUT to gag aor=%s\n",gc->account->username); sippy_send_command( SIMPLE_LOGOUT ); sippy_send_string( gc->account->username ); gaim_debug(GAIM_DEBUG_INFO,"sippy","Removing gag's gaim_input\n"); gaim_input_remove(gc->inpa); }
void sipmsg_print(const struct sipmsg *msg) { GSList *cur; struct siphdrelement *elem; gaim_debug(GAIM_DEBUG_MISC, "simple", "SIP MSG\n"); gaim_debug(GAIM_DEBUG_MISC, "simple", "response: %d\nmethod: %s\nbodylen: %d\n",msg->response,msg->method,msg->bodylen); if(msg->target) gaim_debug(GAIM_DEBUG_MISC, "simple", "target: %s\n",msg->target); cur = msg->headers; while(cur) { elem = cur->data; gaim_debug(GAIM_DEBUG_MISC, "simple", "name: %s value: %s\n",elem->name, elem->value); cur = g_slist_next(cur); } }
/*TODO: maybe this should be qq_update_buddy_status() ?*/ void qq_update_buddy_contact(GaimConnection *gc, qq_buddy *q_bud) { gchar *name; GaimBuddy *bud; gchar *status_id; g_return_if_fail(q_bud != NULL); name = uid_to_gaim_name(q_bud->uid); bud = gaim_find_buddy(gc->account, name); g_return_if_fail(bud != NULL); if (bud != NULL) { gaim_blist_server_alias_buddy(bud, q_bud->nickname); /* server */ q_bud->last_refresh = time(NULL); /* gaim supports signon and idle time * but it is not much use for QQ, I do not use them */ /* serv_got_update(gc, name, online, 0, q_bud->signon, q_bud->idle, bud->uc); */ status_id = "available"; switch(q_bud->status) { case QQ_BUDDY_OFFLINE: status_id = "offline"; break; case QQ_BUDDY_ONLINE_NORMAL: status_id = "available"; break; case QQ_BUDDY_ONLINE_OFFLINE: status_id = "offline"; break; case QQ_BUDDY_ONLINE_AWAY: status_id = "away"; break; case QQ_BUDDY_ONLINE_INVISIBLE: status_id = "invisible"; break; default: status_id = "invisible"; gaim_debug(GAIM_DEBUG_ERROR, "QQ", "unknown status: %x\n", q_bud->status); break; } gaim_debug(GAIM_DEBUG_INFO, "QQ", "set buddy %d to %s\n", q_bud->uid, status_id); gaim_prpl_got_user_status(gc->account, name, status_id, NULL); } else { gaim_debug(GAIM_DEBUG_ERROR, "QQ", "unknown buddy: %d\n", q_bud->uid); } gaim_debug(GAIM_DEBUG_INFO, "QQ", "qq_update_buddy_contact, client=%04x\n", q_bud->client_version); g_free(name); }
/* send IM to a group */ void qq_send_packet_group_im(GaimConnection *gc, qq_group *group, const gchar *msg) { gint data_len, bytes; guint8 *raw_data, *cursor, *send_im_tail; guint16 msg_len; gchar *msg_filtered; g_return_if_fail(group != NULL && msg != NULL); msg_filtered = gaim_markup_strip_html(msg); msg_len = strlen(msg_filtered); data_len = 7 + msg_len + QQ_SEND_IM_AFTER_MSG_LEN; raw_data = g_newa(guint8, data_len); cursor = raw_data; bytes = 0; bytes += create_packet_b(raw_data, &cursor, QQ_GROUP_CMD_SEND_MSG); bytes += create_packet_dw(raw_data, &cursor, group->internal_group_id); bytes += create_packet_w(raw_data, &cursor, msg_len + QQ_SEND_IM_AFTER_MSG_LEN); bytes += create_packet_data(raw_data, &cursor, (guint8 *) msg_filtered, msg_len); send_im_tail = qq_get_send_im_tail(NULL, NULL, NULL, FALSE, FALSE, FALSE, QQ_SEND_IM_AFTER_MSG_LEN); bytes += create_packet_data(raw_data, &cursor, send_im_tail, QQ_SEND_IM_AFTER_MSG_LEN); g_free(send_im_tail); g_free(msg_filtered); if (bytes == data_len) /* create OK */ qq_send_group_cmd(gc, group, raw_data, data_len); else gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Fail creating group_im packet, expect %d bytes, build %d bytes\n", data_len, bytes); }
static int gaym_chat_send(GaimConnection * gc, int id, const char *what) { struct gaym_conn *gaym = gc->proto_data; GaimConversation *convo = gaim_find_chat(gc, id); const char *args[2]; char *tmp; if (!convo) { gaim_debug(GAIM_DEBUG_ERROR, "gaym", "chat send on nonexistent chat\n"); return -EINVAL; } #if 0 if (*what == '/') { return gaym_parse_cmd(gaym, convo->name, what + 1); } #endif args[0] = convo->name; args[1] = what; gaym_cmd_privmsg(gaym, "msg", NULL, args); tmp = gaim_escape_html(what); serv_got_chat_in(gc, id, gaim_connection_get_display_name(gc), 0, tmp, time(NULL)); g_free(tmp); return 0; }
static int irc_chat_send(GaimConnection *gc, int id, const char *what, GaimMessageFlags flags) { struct irc_conn *irc = gc->proto_data; GaimConversation *convo = gaim_find_chat(gc, id); const char *args[2]; char *tmp; if (!convo) { gaim_debug(GAIM_DEBUG_ERROR, "irc", "chat send on nonexistent chat\n"); return -EINVAL; } #if 0 if (*what == '/') { return irc_parse_cmd(irc, convo->name, what + 1); } #endif tmp = gaim_unescape_html(what); args[0] = convo->name; args[1] = tmp; irc_cmd_privmsg(irc, "msg", NULL, args); serv_got_chat_in(gc, id, gaim_connection_get_display_name(gc), 0, what, time(NULL)); g_free(tmp); return 0; }
int gaim_signal_connect_glue(MonoObject* h, MonoObject *plugin, MonoString *signal, MonoObject *func) { char *sig; void **instance = NULL; SignalData *sig_data; GaimMonoPlugin *mplug; MonoClass *klass; sig = mono_string_to_utf8(signal); gaim_debug(GAIM_DEBUG_INFO, "mono", "connecting signal: %s\n", sig); instance = (void*)mono_object_unbox(h); sig_data = g_new0(SignalData, 1); sig_data->func = func; sig_data->signal = sig; gaim_signal_get_values(*instance, sig, &sig_data->ret_value, &sig_data->num_vals, &sig_data->values); klass = mono_object_get_class(plugin); mplug = ml_find_plugin_by_class(klass); mplug->signal_data = g_list_append(mplug->signal_data, (gpointer)sig_data); return gaim_signal_connect(*instance, sig, (gpointer)klass, get_callback(sig_data), (gpointer)sig_data); }
static int ui_main() { #ifndef _WIN32 GList *icons = NULL; GdkPixbuf *icon = NULL; char *icon_path; #endif if (current_smiley_theme == NULL) { smiley_theme_probe(); if (smiley_themes) { struct smiley_theme *smile = smiley_themes->data; load_smiley_theme(smile->path, TRUE); } } gaim_gtk_blist_setup_sort_methods(); #ifndef _WIN32 /* use the nice PNG icon for all the windows */ icon_path = g_build_filename(DATADIR, "pixmaps", "gaim", "icons", "online.png", NULL); icon = gdk_pixbuf_new_from_file(icon_path, NULL); g_free(icon_path); if (icon) { icons = g_list_append(icons,icon); gtk_window_set_default_icon_list(icons); g_object_unref(G_OBJECT(icon)); g_list_free(icons); } else { gaim_debug(GAIM_DEBUG_ERROR, "ui_main", "Failed to load the default window icon!\n"); } #endif return 0; }
static gboolean plugin_load(GaimPlugin *plugin) { gaim_debug(GAIM_DEBUG_INFO, "simple", "simple plugin loaded.\n"); return TRUE; }
/* process the packet when removed from a group */ void qq_process_recv_group_im_been_removed (guint8 *data, guint8 **cursor, gint len, guint32 internal_group_id, GaimConnection *gc) { guint32 external_group_id, uid; guint8 group_type; gchar *msg; qq_group *group; g_return_if_fail(data != NULL && len > 0); if (*cursor >= (data + len - 1)) { gaim_debug(GAIM_DEBUG_WARNING, "QQ", "Received group msg been_removed is empty\n"); return; } read_packet_dw(data, cursor, len, &external_group_id); read_packet_b(data, cursor, len, &group_type); read_packet_dw(data, cursor, len, &uid); g_return_if_fail(external_group_id > 0 && uid > 0); msg = g_strdup_printf(_("You [%d] has exit group \"%d\""), uid, external_group_id); gaim_notify_info(gc, _("QQ Qun Operation"), msg, NULL); group = qq_group_find_by_id(gc, internal_group_id, QQ_INTERNAL_ID); if (group != NULL) { group->my_status = QQ_GROUP_MEMBER_STATUS_NOT_MEMBER; qq_group_refresh(gc, group); } g_free(msg); }
void gaim_connection_destroy(GaimConnection *gc) { GaimAccount *account; g_return_if_fail(gc != NULL); if (gaim_connection_get_state(gc) != GAIM_DISCONNECTED) { gaim_connection_disconnect(gc); return; } gaim_debug(GAIM_DEBUG_INFO, "connection", "Destroying connection %p\n", gc); account = gaim_connection_get_account(gc); gaim_account_set_connection(account, NULL); if (gc->display_name != NULL) g_free(gc->display_name); if (gc->away != NULL) g_free(gc->away); if (gc->away_state != NULL) g_free(gc->away_state); if (gc->disconnect_timeout) g_source_remove(gc->disconnect_timeout); g_free(gc); }
/* parse the return of keep-alive packet, it includes some system information */ void qq_process_keep_alive_reply(guint8 *buf, gint buf_len, GaimConnection *gc) { qq_data *qd; gint len; gchar **segments; guint8 *data; g_return_if_fail(buf != NULL && buf_len != 0); qd = (qq_data *) gc->proto_data; len = buf_len; data = g_newa(guint8, len); if (qq_crypt(DECRYPT, buf, buf_len, qd->session_key, data, &len)) { /* the last one is 60, don't know what it is */ if (NULL == (segments = split_data(data, len, "\x1f", 6))) return; /* segments[0] and segment[1] are all 0x30 ("0") */ qd->all_online = strtol(segments[2], NULL, 10); if(0 == qd->all_online) gaim_connection_error(gc, _("Keep alive error, seems connection lost!")); g_free(qd->my_ip); qd->my_ip = g_strdup(segments[3]); qd->my_port = strtol(segments[4], NULL, 10); g_strfreev(segments); } else gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Error decrypt keep alive reply\n"); /* we refresh buddies's online status periodically */ /* qd->last_get_online is updated when setting get_buddies_online packet */ if ((time(NULL) - qd->last_get_online) >= QQ_UPDATE_ONLINE_INTERVAL) qq_send_packet_get_buddies_online(gc, QQ_FRIENDS_ONLINE_POSITION_START); }
void gaim_connection_register(GaimConnection *gc) { GaimAccount *account; GaimConnectionUiOps *ops; GaimPluginProtocolInfo *prpl_info = NULL; g_return_if_fail(gc != NULL); gaim_debug(GAIM_DEBUG_INFO, "connection", "Registering. gc = %p\n", gc); ops = gaim_get_connection_ui_ops(); if (gc->prpl != NULL) prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); else { gchar *message = g_strdup_printf(_("Missing protocol plugin for %s"), gaim_account_get_username(gaim_connection_get_account(gc))); gaim_debug(GAIM_DEBUG_ERROR, "connection", "Could not get prpl info for %p\n", gc); gaim_notify_error(NULL, _("Registration Error"), message, NULL); g_free(message); return; } account = gaim_connection_get_account(gc); if (gaim_connection_get_state(gc) != GAIM_DISCONNECTED) return; gaim_connection_set_state(gc, GAIM_CONNECTING); connections = g_list_append(connections, gc); gaim_signal_emit(gaim_connections_get_handle(), "signing-on", gc); /* set this so we don't auto-reconnect after registering */ gc->wants_to_die = TRUE; gaim_debug(GAIM_DEBUG_INFO, "connection", "Calling register_user\n"); prpl_info->register_user(account); }
static int trepia_write(int fd, const char *data, size_t len) { gaim_debug(GAIM_DEBUG_MISC, "trepia", "C: %s%c", data, (data[strlen(data) - 1] == '\n' ? '\0' : '\n')); return write(fd, data, len); }
static gboolean sippy_unload_plugin(GaimPlugin *plugin) { if (gaginitialized) { gaim_debug(GAIM_DEBUG_INFO,"sippy","sending SHUTDOWN to gag\n"); sippy_send_command( SIMPLE_SHUTDOWN ); } return 1; }
static void sippy_remove_buddy(GaimConnection *gc, GaimBuddy *who, GaimGroup *group) { if (!gaginitialized) {return;} gaim_debug(GAIM_DEBUG_INFO,"sippy","sending REMOVE BUDDY to gag us=%s them=%s\n",gc->account->username,who->name); sippy_send_command( SIMPLE_REMOVE_BUDDY ); sippy_send_string( gc->account->username ); sippy_send_string( who->name ); }
void yahoo_process_chat_message(GaimConnection *gc, struct yahoo_packet *pkt) { char *room = NULL, *who = NULL, *msg = NULL, *msg2; int msgtype = 1, utf8 = 1; /* default to utf8 */ GaimConversation *c = NULL; GSList *l; for (l = pkt->hash; l; l = l->next) { struct yahoo_pair *pair = l->data; switch (pair->key) { case 97: utf8 = strtol(pair->value, NULL, 10); break; case 104: room = yahoo_string_decode(gc, pair->value, TRUE); break; case 109: who = pair->value; break; case 117: msg = pair->value; break; case 124: msgtype = strtol(pair->value, NULL, 10); break; } } c = gaim_find_chat(gc, YAHOO_CHAT_ID); if (!who || !c) { if (room) g_free(room); /* we still get messages after we part, funny that */ return; } if (!msg) { gaim_debug(GAIM_DEBUG_MISC, "yahoo", "Got a message packet with no message.\nThis probably means something important, but we're ignoring it.\n"); return; } msg2 = yahoo_string_decode(gc, msg, utf8); msg = yahoo_codes_to_html(msg2); g_free(msg2); if (msgtype == 2 || msgtype == 3) { char *tmp; tmp = g_strdup_printf("/me %s", msg); g_free(msg); msg = tmp; } serv_got_chat_in(gc, YAHOO_CHAT_ID, who, 0, msg, time(NULL)); g_free(msg); g_free(room); }
static void stringref_free(GaimStringref *stringref) { #ifdef DEBUG if (REFCOUNT(stringref->ref) != 0) { gaim_debug(GAIM_DEBUG_ERROR, "stringref", "Free of nonzero (%d) ref stringref!\n", REFCOUNT(stringref->ref)); return; } #endif /* DEBUG */ g_free(stringref); }
static void dequeue_message(GtkTreeIter *iter) { gchar *name; GSList *templist; GaimConversation *cnv; gboolean orig_while_away; orig_while_away = gaim_prefs_get_bool("/core/sound/while_away"); if (orig_while_away) gaim_prefs_set_bool("/core/sound/while_away", FALSE); gtk_tree_model_get(GTK_TREE_MODEL(awayqueuestore), iter, 0, &name, -1); gaim_debug(GAIM_DEBUG_INFO, "away", "Dequeueing messages from %s.\n", name); templist = message_queue; while (templist) { struct queued_message *qm = templist->data; if (templist->data) { if (!gaim_utf8_strcasecmp(qm->name, name)) { GaimAccount *account = NULL; if (g_list_index(gaim_accounts_get_all(), qm->account) >= 0) account = qm->account; cnv = gaim_find_conversation_with_account(name, account); if (!cnv) cnv = gaim_conversation_new(GAIM_CONV_IM, account, qm->name); else gaim_conversation_set_account(cnv, account); gaim_conv_im_write(GAIM_CONV_IM(cnv), NULL, qm->message, qm->flags, qm->tm); g_free(qm->message); g_free(qm); templist = message_queue = g_slist_remove(message_queue, qm); } else { templist = templist->next; } } } g_free(name); /* In GTK 2.2, _store_remove actually returns whether iter is valid or not * after the remove, but in GTK 2.0 it is a void function. */ gtk_list_store_remove(awayqueuestore, iter); if (orig_while_away) gaim_prefs_set_bool("/core/sound/while_away", orig_while_away); }
static char * __get_mac_address(const char *ip) { char *mac = NULL; #ifndef _WIN32 struct sockaddr_in sin = { 0 }; struct arpreq myarp = { { 0 } }; int sockfd; unsigned char *ptr; sin.sin_family = AF_INET; if (inet_aton(ip, &sin.sin_addr) == 0) { gaim_debug(GAIM_DEBUG_ERROR, "trepia", "Invalid IP address %s\n", ip); return NULL; } memcpy(&myarp.arp_pa, &sin, sizeof(myarp.arp_pa)); strcpy(myarp.arp_dev, "eth0"); if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { gaim_debug(GAIM_DEBUG_ERROR, "trepia", "Cannot open socket for retrieving MAC address.\n"); return NULL; } if (ioctl(sockfd, SIOCGARP, &myarp) == -1) { gaim_debug(GAIM_DEBUG_ERROR, "trepia", "No entry in in arp_cache for %s\n", ip); return NULL; } ptr = &myarp.arp_ha.sa_data[0]; mac = g_strdup_printf("%x:%x:%x:%x:%x:%x", ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5]); #else #endif return mac; }
char * msn_page_build_string(const MsnPage *page) { char *page_start; char *str; char buf[MSN_BUF_LEN]; int len; /* * Okay, how we do things here is just bad. I don't like writing to * a static buffer and then copying to the string. Unfortunately, * just trying to append to the string is causing issues.. Such as * the string you're appending to being erased. Ugh. So, this is * good enough for now. * * -- ChipX86 */ g_return_val_if_fail(page != NULL, NULL); if (msn_page_is_incoming(page)) { /* We don't know this yet :) */ return NULL; } else { MsnUser *receiver = msn_page_get_receiver(page); g_snprintf(buf, sizeof(buf), "PAG %d %s %d\r\n", msn_page_get_transaction_id(page), msn_user_get_passport(receiver), page->size); } len = strlen(buf) + page->size + 1; str = g_new0(char, len); g_strlcpy(str, buf, len); page_start = str + strlen(str); g_snprintf(buf, sizeof(buf), "<TEXT>%s</TEXT>", msn_page_get_body(page)); g_strlcat(str, buf, len); if (page->size != strlen(page_start)) { gaim_debug(GAIM_DEBUG_ERROR, "msn", "Outgoing page size (%d) and string length (%d) " "do not match!\n", page->size, strlen(page_start)); } return str; }
static void ice_process_messages(gpointer data, gint fd, GaimInputCondition condition) { struct ice_connection_info *conninfo = (struct ice_connection_info*) data; IceProcessMessagesStatus status; /* please don't block... please! */ status = IceProcessMessages(conninfo->connection, NULL, NULL); if (status == IceProcessMessagesIOError) { gaim_debug(GAIM_DEBUG_INFO, "Session Management", "ICE IO error, closing connection... "); /* IO error, please disconnect */ IceSetShutdownNegotiation(conninfo->connection, False); IceCloseConnection(conninfo->connection); gaim_debug(GAIM_DEBUG_INFO, "Session Management", "done."); /* cancel the handler */ gaim_input_remove(conninfo->input_id); } }
void gaim_connection_disconnect(GaimConnection *gc) { GaimAccount *account; GList *wins; g_return_if_fail(gc != NULL); account = gaim_connection_get_account(gc); if (gaim_account_get_connection(account) != NULL) { gaim_account_disconnect(account); return; } gaim_debug(GAIM_DEBUG_INFO, "connection", "Disconnecting connection %p\n", gc); if (gaim_connection_get_state(gc) != GAIM_DISCONNECTED) { if (gaim_connection_get_state(gc) != GAIM_CONNECTING) gaim_blist_remove_account(gaim_connection_get_account(gc)); gaim_signal_emit(gaim_connections_get_handle(), "signing-off", gc); serv_close(gc); connections = g_list_remove(connections, gc); gaim_connection_set_state(gc, GAIM_DISCONNECTED); gaim_signal_emit(gaim_connections_get_handle(), "signed-off", gc); system_log(log_signoff, gc, NULL, OPT_LOG_BUDDY_SIGNON | OPT_LOG_MY_SIGNON); /* * XXX This is a hack! Remove this and replace it with a better event * notification system. */ for (wins = gaim_get_windows(); wins != NULL; wins = wins->next) { GaimWindow *win = (GaimWindow *)wins->data; gaim_conversation_update(gaim_window_get_conversation_at(win, 0), GAIM_CONV_ACCOUNT_OFFLINE); } gaim_request_close_with_handle(gc); gaim_notify_close_with_handle(gc); } gaim_connection_destroy(gc); }