Ejemplo n.º 1
0
Archivo: odc.c Proyecto: VoxOx/VoxOx
/**
 * Write the given OdcFrame to a ByteStream and send it out
 * on the established PeerConnection.
 */
static void
peer_odc_send(PeerConnection *conn, OdcFrame *frame)
{
    GaimAccount *account;
    const char *username;
    size_t length;
    ByteStream bs;

    gaim_debug_info("oscar", "Outgoing ODC frame to %s with "
                    "type=0x%04x, flags=0x%04x, payload length=%u\n",
                    conn->sn, frame->type, frame->flags, frame->payload.len);

    account = gaim_connection_get_account(conn->od->gc);
    username = gaim_account_get_username(account);
    memcpy(frame->sn, username, strlen(username));
    memcpy(frame->cookie, conn->cookie, 8);

    length = 76;
    byte_stream_new(&bs, length + frame->payload.len);
    byte_stream_putraw(&bs, conn->magic, 4);
    byte_stream_put16(&bs, length);
    byte_stream_put16(&bs, frame->type);
    byte_stream_put16(&bs, frame->subtype);
    byte_stream_put16(&bs, 0x0000);
    byte_stream_putraw(&bs, frame->cookie, 8);
    byte_stream_put16(&bs, 0x0000);
    byte_stream_put16(&bs, 0x0000);
    byte_stream_put16(&bs, 0x0000);
    byte_stream_put16(&bs, 0x0000);
    byte_stream_put32(&bs, frame->payload.len);
    byte_stream_put16(&bs, 0x0000);
    byte_stream_put16(&bs, frame->encoding);
    byte_stream_put16(&bs, 0x0000);
    byte_stream_put16(&bs, frame->flags);
    byte_stream_put16(&bs, 0x0000);
    byte_stream_put16(&bs, 0x0000);
    byte_stream_putraw(&bs, frame->sn, 32);
    byte_stream_putraw(&bs, frame->payload.data, frame->payload.len);

    peer_connection_send(conn, &bs);

    g_free(bs.data);
}
Ejemplo n.º 2
0
MsnMessage *
msn_message_new(MsnMsgType type)
{
    MsnMessage *msg;

    msg = g_new0(MsnMessage, 1);
    msg->type = type;

#ifdef MSN_DEBUG_MSG
    gaim_debug_info("msn", "message new (%p)(%d)\n", msg, type);
#endif

    msg->attr_table = g_hash_table_new_full(g_str_hash, g_str_equal,
                                            g_free, g_free);

    msn_message_ref(msg);

    return msg;
}
Ejemplo n.º 3
0
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);
}
Ejemplo n.º 4
0
Archivo: dnssrv.c Proyecto: VoxOx/VoxOx
static void
resolved(gpointer data, gint source, GaimInputCondition cond)
{
	int size;
	GaimSrvQueryData *query_data = (GaimSrvQueryData*)data;
	GaimSrvResponse *res;
	GaimSrvResponse *tmp;
	int i;
	GaimSrvCallback cb = query_data->cb;

	read(source, &size, sizeof(int));
	gaim_debug_info("dnssrv","found %d SRV entries\n", size);
	tmp = res = g_new0(GaimSrvResponse, size);
	for (i = 0; i < size; i++) {
		read(source, tmp++, sizeof(GaimSrvResponse));
	}

	cb(res, size, query_data->extradata);

	gaim_srv_cancel(query_data);
}
Ejemplo n.º 5
0
NMRequest *nm_create_request(const char *cmd, int trans_id, int gmt, nm_response_cb cb,
                             gpointer resp_data, gpointer user_define)
{
    NMRequest *req;

    if (cmd == NULL)
        return NULL;

    req  = g_new0(NMRequest, 1);
    req->cmd = g_strdup(cmd);
    req->trans_id = trans_id;
    req->gmt = gmt;
    req->callback = cb;
    req->data = resp_data;
    req->user_define = user_define;
    req->ref_count = 1;

    gaim_debug_info("novell", "Creating NMRequest instance, total=%d\n", ++count);

    return req;
}
Ejemplo n.º 6
0
Archivo: dnssrv.c Proyecto: VoxOx/VoxOx
static gboolean
res_main_thread_cb(gpointer data)
{
	GaimSrvResponse *srvres = NULL;
	int size = 0;
	GaimSrvQueryData *query_data = data;

	if(query_data->error_message != NULL)
		gaim_debug_error("dnssrv", query_data->error_message);
	else {
		GaimSrvResponse *srvres_tmp = NULL;
		GSList *lst = query_data->results;

		size = g_slist_length(query_data->results);

		if(query_data->cb)
			srvres_tmp = srvres = g_new0(GaimSrvResponse, size);
		while (lst) {
			if(query_data->cb)
				memcpy(srvres_tmp++, lst->data, sizeof(GaimSrvResponse));
			g_free(lst->data);
			lst = g_slist_remove(lst, lst->data);
		}

		query_data->results = NULL;
	}

	gaim_debug_info("dnssrv", "found %d SRV entries\n", size);

	if(query_data->cb)
		query_data->cb(srvres, size, query_data->extradata);

	query_data->resolver = NULL;
	query_data->handle = 0;

	gaim_srv_cancel(query_data);

	return FALSE;
}
Ejemplo n.º 7
0
MsnMessage *
msn_message_unref(MsnMessage *msg)
{
    g_return_val_if_fail(msg != NULL, NULL);

    if (msg->ref_count <= 0)
        return NULL;

    msg->ref_count--;

#ifdef MSN_DEBUG_MSG
    gaim_debug_info("msn", "message unref (%p)[%d]\n", msg, msg->ref_count);
#endif

    if (msg->ref_count == 0)
    {
        msn_message_destroy(msg);

        return NULL;
    }

    return msg;
}
Ejemplo n.º 8
0
Archivo: si.c Proyecto: VoxOx/VoxOx
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);
}
Ejemplo n.º 9
0
void
gaim_session_fetch(const char *url, gboolean full,
                   const char *user_agent, gboolean http11,
                   void (*cb) (gpointer, const char *, size_t),
                   void *user_data, GaimUrlSession * session)
{
    int sock;
    GaimFetchUrlData *gfud;

    g_return_if_fail(url != NULL);
    g_return_if_fail(cb != NULL);

    gaim_debug_info("gaim_session_fetch",
                    "requested to fetch (%s), full=%d, user_agent=(%s), http11=%d\n",
                    url, full, user_agent ? user_agent : "(null)", http11);

    gfud = g_new0(GaimFetchUrlData, 1);

    gfud->callback = cb;
    gfud->user_data = user_data;
    gfud->url = g_strdup(url);
    gfud->user_agent = (user_agent != NULL ? g_strdup(user_agent) : NULL);
    gfud->http11 = http11;
    gfud->full = full;
    gfud->session = session;
    gaim_url_parse(url, &gfud->website.address, &gfud->website.port,
                   &gfud->website.page, &gfud->website.user,
                   &gfud->website.passwd);

    if ((sock = gaim_proxy_connect(NULL, gfud->website.address,
                                   gfud->website.port, session_fetched_cb,
                                   gfud)) < 0) {
        destroy_fetch_url_data(gfud);

        cb(user_data, g_strdup(_("g003: Error opening connection.\n")), 0);
    }
}
Ejemplo n.º 10
0
Archivo: dnssrv.c Proyecto: VoxOx/VoxOx
GaimSrvQueryData *
gaim_srv_resolve(const char *protocol, const char *transport, const char *domain, GaimSrvCallback cb, gpointer extradata)
{
	char *query;
	GaimSrvQueryData *query_data;
#ifndef _WIN32
	int in[2], out[2];
	int pid;
#else
	GError* err = NULL;
	static gboolean initialized = FALSE;
#endif

	query = g_strdup_printf("_%s._%s.%s", protocol, transport, domain);
	gaim_debug_info("dnssrv","querying SRV record for %s\n", query);

#ifndef _WIN32
	if(pipe(in) || pipe(out)) {
		gaim_debug_error("dnssrv", "Could not create pipe\n");
		g_free(query);
		cb(NULL, 0, extradata);
		return NULL;
	}

	pid = fork();
	if (pid == -1) {
		gaim_debug_error("dnssrv", "Could not create process!\n");
		cb(NULL, 0, extradata);
		g_free(query);
		return NULL;
	}

	/* Child */
	if (pid == 0)
	{
		close(out[0]);
		close(in[1]);
		resolve(in[0], out[1]);
	}

	close(out[1]);
	close(in[0]);

	if (write(in[1], query, strlen(query)+1) < 0)
		gaim_debug_error("dnssrv", "Could not write to SRV resolver\n");

	query_data = g_new0(GaimSrvQueryData, 1);
	query_data->cb = cb;
	query_data->extradata = extradata;
	query_data->handle = gaim_input_add(out[0], GAIM_INPUT_READ, resolved, query_data);

	g_free(query);

	return query_data;
#else
	if (!initialized) {
		MyDnsQuery_UTF8 = (void*) wgaim_find_and_loadproc("dnsapi.dll", "DnsQuery_UTF8");
		MyDnsRecordListFree = (void*) wgaim_find_and_loadproc(
			"dnsapi.dll", "DnsRecordListFree");
		initialized = TRUE;
	}

	query_data = g_new0(GaimSrvQueryData, 1);
	query_data->cb = cb;
	query_data->query = query;
	query_data->extradata = extradata;

	if (!MyDnsQuery_UTF8 || !MyDnsRecordListFree) {
		query_data->error_message = g_strdup_printf("System missing DNS API (Requires W2K+)\n");

		/* Asynchronously call the callback since stuff may not expect
		 * the callback to be called before this returns */
		query_data->handle = g_idle_add(res_main_thread_cb, query_data);

		return query_data;
	}

	query_data->resolver = g_thread_create(res_thread, query_data, FALSE, &err);
	if (query_data->resolver == NULL)
	{
		query_data->error_message = g_strdup_printf("SRV thread create failure: %s\n", err ? err->message : "");
		g_error_free(err);

		/* Asynchronously call the callback since stuff may not expect
		 * the callback to be called before this returns */
		query_data->handle = g_idle_add(res_main_thread_cb, query_data);

		return query_data;
	}

	return query_data;
#endif
}
Ejemplo n.º 11
0
static void gaym_set_info(GaimConnection * gc, const char *info)
{
    struct gaym_conn *gaym = gc->proto_data;
    GaimAccount *account = gaim_connection_get_account(gc);
    char *hostname = "none";
    char *buf, *bioline;
    int i = 0;

    char *tmpinfo = NULL;
    if (info) {
        tmpinfo = g_strdup(info);
        for (i = 0; i < strlen(tmpinfo); i++) {
            if (tmpinfo[i] == '\n') {
                tmpinfo[i] = ' ';
            }
        }
        tmpinfo = g_strstrip(tmpinfo);
    }

    if (gc->away && !tmpinfo) {
        /**
         * don't change any bio settings, since this is just
         * setting an away message
         */
    } else {
        if (gaym->bio) {
            g_free(gaym->bio);
        }
        if (tmpinfo && strlen(tmpinfo) > 0) {
            gaim_debug_misc("gaym", "option1, info=%x\n", tmpinfo);
            /* java client allows MAX_BIO_LEN characters */
            gaym->bio = g_strndup(tmpinfo, MAX_BIO_LEN);
        } else if (gaym->server_bioline
                   && strlen(gaym->server_bioline) > 0) {
            gaim_debug_misc("gaym", "option2\n");
            gaym->bio = gaym_bio_strdup(gaym->server_bioline);
        } else {
            gaim_debug_misc("gaym", "option3\n");
            gaym->bio = g_strdup("Gaim User");
        }
        gaim_account_set_user_info(account, gaym->bio);
        gaim_account_set_string(account, "bioline", gaym->bio);
        gaim_debug_info("gaym", "INFO=%x BIO=%x\n", tmpinfo, gaym->bio);
        gaim_debug_misc("gaym", "In login_cb, gc->account=%x\n",
                        gc->account);
    }

    bioline =
        g_strdup_printf("%s#%s\xC2\xA0 \xC2\xA0\001%s",
                        gaym->thumbnail ? gaym->thumbnail : "",
                        gc->away ? gc->away : (gaym->bio ? gaym->bio : ""),
                        gaym->server_stats ? gaym->server_stats : "");

    buf = gaym_format(gaym, "vvvv:", "USER",
                      gaim_account_get_username(account),
                      hostname, gaym->server, bioline);

    gaim_debug_misc("gaym", "BIO=%x\n", bioline);

    if (gaym_send(gaym, buf) < 0) {
        gaim_connection_error(gc, "Error registering with server");
    }

    if (tmpinfo) {
        g_free(tmpinfo);
    }
    g_free(bioline);
    g_free(buf);

    return;
}
Ejemplo n.º 12
0
static void gaym_login_cb(gpointer data, gint source,
                          GaimInputCondition cond)
{
    GaimConnection *gc = data;
    struct gaym_conn *gaym = gc->proto_data;
    char hostname[256];
    char *buf;
    const char *username;
    const char *user_bioline = NULL;
    char *bioline;
    char *login_name;

    if (GAIM_CONNECTION_IS_VALID(gc)) {


        GList *connections = gaim_connections_get_all();

        if (source < 0) {
            gaim_connection_error(gc, _("Couldn't connect to host"));
            return;
        }

        if (!g_list_find(connections, gc)) {
            close(source);
            return;
        }

        gaym->fd = source;
        gaim_debug_misc("gaym", "In login_cb with chat_key=%s\n",
                        gaym->chat_key);
        if (gaym->chat_key) {

            buf = gaym_format(gaym, "vv", "PASS", gaym->chat_key);
            if (gaym_send(gaym, buf) < 0) {
                gaim_connection_error(gc, "Error sending password");
                return;
            }
            g_free(buf);
        } else {
            gaim_connection_error(gc,
                                  _
                                  ("Password wasn't recorded. Report bug."));
            return;
        }
        gethostname(hostname, sizeof(hostname));
        hostname[sizeof(hostname) - 1] = '\0';
        username = gaim_account_get_string(gaym->account, "username", "");
        user_bioline =
            g_strdup(gaim_account_get_string
                     (gaym->account, "bioline", ""));
        gaim_debug_info("gaym", "USER BIOLINE=%x\n", user_bioline);
        gaim_account_set_user_info(gc->account, user_bioline);
        gaim_debug_misc("gaym",
                        "In login_cb, user_bioline: %x, gc->account=%x\n",
                        user_bioline, gc->account);

        login_name =
            gaym_nick_to_gcom_strdup(gaim_connection_get_display_name(gc));
        bioline = g_strdup_printf("%s#%s\xC2\xA0 \xC2\xA0\001%s",
                                  gaym->thumbnail,
                                  user_bioline ? user_bioline : "",
                                  gaym->server_stats ? gaym->
                                  server_stats : "");

        buf = gaym_format(gaym, "vn", "NICK", login_name);
        gaim_debug_misc("gaym", "Command: %s\n", buf);

        if (gaym_send(gaym, buf) < 0) {
            gaim_connection_error(gc, "Error sending nickname");
            return;
        }
        g_free(buf);
        buf =
            gaym_format(gaym, "vvvv:", "USER", login_name, hostname,
                        gaym->server, bioline);

        gaim_debug_misc("gaym", "Command: %s\n", buf);
        if (gaym_send(gaym, buf) < 0) {
            gaim_connection_error(gc, "Error registering with server");
            return;
        }
        g_free(login_name);
        g_free(buf);

        const char *server = gaim_account_get_string(gc->account, "server",
                                                     IRC_DEFAULT_SERVER);
        char *url =
            g_strdup_printf
            ("http://%s/messenger/config.txt?%s", server, gaym->chat_key);

        char *user_agent = "Mozilla/4.0";

        get_spamlist_from_web();
        gaim_url_fetch(url, FALSE, user_agent, FALSE,
                       gaym_get_configtxt_cb, gaym);

        g_free(url);
        gc->inpa =
            gaim_input_add(gaym->fd, GAIM_INPUT_READ, gaym_input_cb, gc);


    }
}
Ejemplo n.º 13
0
void yahoo_process_chat_join(GaimConnection *gc, struct yahoo_packet *pkt)
{
	GaimAccount *account = gaim_connection_get_account(gc);
	struct yahoo_data *yd = (struct yahoo_data *) gc->proto_data;
	GaimConversation *c = NULL;
	GSList *l;
	GList *members = NULL;
	GList *roomies = NULL;
	char *room = NULL;
	char *topic = NULL;
	char *someid, *someotherid, *somebase64orhashosomething, *somenegativenumber;

	if (pkt->status == -1) {
		/* We can't join */
		struct yahoo_pair *pair = pkt->hash->data;
		gchar const *failed_to_join = _("Failed to join chat");
		switch (atoi(pair->value)) {
			case 0xFFFFFFFA: /* -6 */
				gaim_notify_error(gc, NULL, failed_to_join, _("Unknown room"));
				break;
			case 0xFFFFFFF1: /* -15 */
				gaim_notify_error(gc, NULL, failed_to_join, _("Maybe the room is full"));
				break;
			case 0xFFFFFFDD: /* -35 */
				gaim_notify_error(gc, NULL, failed_to_join, _("Not available"));
				break;
			default:
				gaim_notify_error(gc, NULL, failed_to_join,
						_("Unknown error. You may need to logout and wait five minutes before being able to rejoin a chatroom"));
		}
		return;
	}

	for (l = pkt->hash; l; l = l->next) {
		struct yahoo_pair *pair = l->data;

		switch (pair->key) {

		case 104:
			room = yahoo_string_decode(gc, pair->value, TRUE);
			break;
		case 105:
			topic = yahoo_string_decode(gc, pair->value, TRUE);
			break;
		case 128:
			someid = pair->value;
			break;
		case 108: /* number of joiners */
			break;
		case 129:
			someotherid = pair->value;
			break;
		case 130:
			somebase64orhashosomething = pair->value;
			break;
		case 126:
			somenegativenumber = pair->value;
			break;
		case 13: /* this is 1. maybe its the type of room? (normal, user created, private, etc?) */
			break;
		case 61: /*this looks similar to 130 */
			break;

		/* the previous section was just room info. this next section is
		   info about individual room members, (including us) */

		case 109: /* the yahoo id */
			members = g_list_append(members, pair->value);
			break;
		case 110: /* age */
			break;
		case 141: /* nickname */
			break;
		case 142: /* location */
			break;
		case 113: /* bitmask */
			break;
		}
	}

	if (room && yd->chat_name && gaim_utf8_strcasecmp(room, yd->chat_name))
		yahoo_chat_leave(gc, room,
				gaim_connection_get_display_name(gc), FALSE);

	c = gaim_find_chat(gc, YAHOO_CHAT_ID);

	if (room && (!c || gaim_conv_chat_has_left(GAIM_CONV_CHAT(c))) && members &&
	   ((g_list_length(members) > 1) ||
	     !g_ascii_strcasecmp(members->data, gaim_connection_get_display_name(gc)))) {
		int i;
		GList *flags = NULL;
		for (i = 0; i < g_list_length(members); i++)
			flags = g_list_append(flags, GINT_TO_POINTER(GAIM_CBFLAGS_NONE));
		if (c && gaim_conv_chat_has_left(GAIM_CONV_CHAT(c))) {
			/* this might be a hack, but oh well, it should nicely */
			char *tmpmsg;

			gaim_conversation_set_name(c, room);

			c = serv_got_joined_chat(gc, YAHOO_CHAT_ID, room);
			if (topic)
				gaim_conv_chat_set_topic(GAIM_CONV_CHAT(c), NULL, topic);
			yd->in_chat = 1;
			yd->chat_name = g_strdup(room);
			gaim_conv_chat_add_users(GAIM_CONV_CHAT(c), members, NULL, flags, FALSE);

			tmpmsg = g_strdup_printf(_("You are now chatting in %s."), room);
			gaim_conv_chat_write(GAIM_CONV_CHAT(c), "", tmpmsg, GAIM_MESSAGE_SYSTEM, time(NULL));
			g_free(tmpmsg);
		} else {
			c = serv_got_joined_chat(gc, YAHOO_CHAT_ID, room);
			if (topic)
				gaim_conv_chat_set_topic(GAIM_CONV_CHAT(c), NULL, topic);
			yd->in_chat = 1;
			yd->chat_name = g_strdup(room);
			gaim_conv_chat_add_users(GAIM_CONV_CHAT(c), members, NULL, flags, FALSE);
		}
		g_list_free(flags);
	} else if (c) {
		yahoo_chat_add_users(GAIM_CONV_CHAT(c), members);
	}

	if (account->deny && c) {
		GaimConversationUiOps *ops = gaim_conversation_get_ui_ops(c);
		for (l = account->deny; l != NULL; l = l->next) {
			for (roomies = members; roomies; roomies = roomies->next) {
				if (!gaim_utf8_strcasecmp((char *)l->data, roomies->data)) {
					gaim_debug_info("yahoo", "Ignoring room member %s in room %s\n" , roomies->data, room ? room : "");
					gaim_conv_chat_ignore(GAIM_CONV_CHAT(c),roomies->data);
					ops->chat_update_user(c, roomies->data);
				}
			}
		}
	}
	g_list_free(roomies);
	g_list_free(members);
	g_free(room);
	g_free(topic);
}
Ejemplo n.º 14
0
void yahoo_process_conference_invite(GaimConnection *gc, struct yahoo_packet *pkt)
{
	GSList *l;
	char *room = NULL;
	char *who = NULL;
	char *msg = NULL;
	GString *members = NULL;
	GHashTable *components;

	if (pkt->status == 2)
		return; /* XXX */

	members = g_string_sized_new(512);

	for (l = pkt->hash; l; l = l->next) {
		struct yahoo_pair *pair = l->data;

		switch (pair->key) {
		case 1: /* us, but we already know who we are */
			break;
		case 57:
			room = yahoo_string_decode(gc, pair->value, FALSE);
			break;
		case 50: /* inviter */
			who = pair->value;
			g_string_append_printf(members, "%s\n", who);
			break;
		case 52: /* invitee (me) */
		case 53: /* members */
			g_string_append_printf(members, "%s\n", pair->value);
			break;
		case 58:
			msg = yahoo_string_decode(gc, pair->value, FALSE);
			break;
		case 13: /* ? */
			break;
		}
	}

	if (!room) {
		g_string_free(members, TRUE);
		return;
	}

	components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
	g_hash_table_replace(components, g_strdup("room"), room);
	if (msg)
		g_hash_table_replace(components, g_strdup("topic"), msg);
	g_hash_table_replace(components, g_strdup("type"), g_strdup("Conference"));
	if (members) {
		g_hash_table_replace(components, g_strdup("members"), g_strdup(members->str));
	}
	if (!yahoo_privacy_check(gc, who) || 
		(gaim_account_get_bool(gaim_connection_get_account(gc), "ignore_invites", FALSE))) {
		gaim_debug_info("yahoo",
		    "Invite to conference %s from %s has been dropped.\n", room, who);
		g_string_free(members, TRUE);
		return;
	}
	serv_got_chat_invite(gc, room, who, msg, components);

	g_string_free(members, TRUE);
}
Ejemplo n.º 15
0
static void
gaym_weblogin_step5(gpointer session, const char* text, size_t len) {

	struct gaym_conn *gaym=(struct gaym_conn*)session;
	//Get hash from text
	if(GAIM_CONNECTION_IS_VALID(gaym->account->gc))
	{
	char *pw_hash;
	char *bio;
	char *thumbnail;
	char *temp=NULL;
	char *temp2=NULL;
	const char* match;
	const char* result;
	
	
	
	
	//First, look for password
	match="password\" value=\""; 
	temp=strstr(text, match);
	if(temp)
	{
		temp+=strlen(match);
		temp2=strstr(temp,"\" ");
	}
	if(temp && temp2)
	{
		pw_hash=g_strndup(temp,(temp2-temp)*sizeof(char));
		
		(gaym->hash_pw=g_strdup(pw_hash)) 
				|| (gaym->hash_pw=g_strdup(" "));
		g_free(pw_hash);
	}
	else
	{
		gaim_connection_error(
			(gaym->account->gc),
			_("Problem parsing password from web. Report a bug."));
	}
	
	//Next, loook for bio
	match="param name=\"bio\" value=\"";
	temp=strstr(text,match);
	if(temp)
	{
		temp+=strlen(match);
		temp2=strstr(temp,"%23");
	}
	if(temp && temp2)
	{
		thumbnail=g_strndup(temp,(temp2-temp)*sizeof(char));
		result=gaym_url_decode(thumbnail);
		(gaym->thumbnail=g_strdup(result)) ||(gaym->thumbnail=g_strdup(" "));
		
		g_free(thumbnail);
		//Parse out non	thumbnail part of bio.
		temp=strstr(temp2,"\"");
		if(temp) 
		{
			bio=g_strndup(temp2,(temp-temp2)*sizeof(char));
			result=gaym_url_decode(bio);
			gaim_debug_info("gaym","Server BIO: %s Thumb: %s\n",
				result, gaym->thumbnail);
			(gaym->server_bioline=g_strdup(result))
					||(gaym->server_bioline=NULL);
			g_free(bio);
			
		}
		//We have established a session. Call session callback.
		
	}
	else
	{
		//gaim_connection_error(
		//		gaim_account_get_connection(((struct gaym_conn*)((GaimUrlSession*)session)->account),
		//		_("Problem parsing password from web. Report a bug."));
	}
	gaym->session->session_cb(gaym->account);
	
	}
	
	
}
Ejemplo n.º 16
0
void
msn_switchboard_destroy(MsnSwitchBoard *swboard)
{
	MsnSession *session;
	MsnMessage *msg;
	GList *l;

#ifdef MSN_DEBUG_SB
	gaim_debug_info("msn", "switchboard_destroy: swboard(%p)\n", swboard);
#endif

	g_return_if_fail(swboard != NULL);

	if (swboard->destroying)
		return;

	swboard->destroying = TRUE;

	/* If it linked us is because its looking for trouble */
	while (swboard->slplinks != NULL)
		msn_slplink_destroy(swboard->slplinks->data);

	/* Destroy the message queue */
	while ((msg = g_queue_pop_head(swboard->msg_queue)) != NULL)
	{
		if (swboard->error != MSN_SB_ERROR_NONE)
		{
			/* The messages could not be sent due to a switchboard error */
			msg_error_helper(swboard->cmdproc, msg,
							 MSN_MSG_ERROR_SB);
		}
		msn_message_unref(msg);
	}

	g_queue_free(swboard->msg_queue);

	/* msg_error_helper will both remove the msg from ack_list and
	   unref it, so we don't need to do either here */
	while ((l = swboard->ack_list) != NULL)
		msg_error_helper(swboard->cmdproc, l->data, MSN_MSG_ERROR_SB);

	g_free(swboard->im_user);
	g_free(swboard->auth_key);
	g_free(swboard->session_id);

	for (l = swboard->users; l != NULL; l = l->next)
		g_free(l->data);

	session = swboard->session;
	session->switches = g_list_remove(session->switches, swboard);

#if 0
	/* This should never happen or we are in trouble. */
	if (swboard->servconn != NULL)
		msn_servconn_destroy(swboard->servconn);
#endif

	swboard->cmdproc->data = NULL;

	msn_servconn_set_disconnect_cb(swboard->servconn, NULL);

	msn_servconn_destroy(swboard->servconn);

	g_free(swboard);
}
Ejemplo n.º 17
0
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");
	}
}
Ejemplo n.º 18
0
void
gaim_connection_new(GaimAccount *account, gboolean regist, const char *password)
{
	GaimConnection *gc;
	GaimPlugin *prpl;
	GaimPluginProtocolInfo *prpl_info;

	g_return_if_fail(account != NULL);

	if (!gaim_account_is_disconnected(account))
		return;

	prpl = gaim_find_prpl(gaim_account_get_protocol_id(account));

	if (prpl != NULL)
		prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl);
	else {
		gchar *message;

		message = g_strdup_printf(_("Missing protocol plugin for %s"),
			gaim_account_get_username(account));
		gaim_notify_error(NULL, regist ? _("Registration Error") :
						  _("Connection Error"), message, NULL);
		g_free(message);
		return;
	}

	if (regist)
	{
		if (prpl_info->register_user == NULL)
			return;
	}
	else
	{
		if (((password == NULL) || (*password == '\0')) &&
			!(prpl_info->options & OPT_PROTO_NO_PASSWORD) &&
			!(prpl_info->options & OPT_PROTO_PASSWORD_OPTIONAL))
		{
			gaim_debug_error("connection", "Can not connect to account %s without "
							 "a password.\n", gaim_account_get_username(account));
			return;
		}
	}

	gc = g_new0(GaimConnection, 1);
	GAIM_DBUS_REGISTER_POINTER(gc, GaimConnection);

	gc->prpl = prpl;
	if ((password != NULL) && (*password != '\0'))
		gc->password = g_strdup(password);
	gaim_connection_set_account(gc, account);
	gaim_connection_set_state(gc, GAIM_CONNECTING);
	connections = g_list_append(connections, gc);
	gaim_account_set_connection(account, gc);

	gaim_signal_emit(gaim_connections_get_handle(), "signing-on", gc);

	if (regist)
	{
		gaim_debug_info("connection", "Registering.  gc = %p\n", gc);

		/* set this so we don't auto-reconnect after registering */
		gc->wants_to_die = TRUE;

		prpl_info->register_user(account);
	}
	else
	{
		gaim_debug_info("connection", "Connecting. gc = %p\n", gc);

		gaim_signal_emit(gaim_accounts_get_handle(), "account-connecting", account);
		prpl_info->login(account);
	}
}
Ejemplo n.º 19
0
static void
gaym_weblogin_step5(gpointer session, const char *text, size_t len)
{

    struct gaym_conn *gaym = (struct gaym_conn *) session;
    // Get hash from text
    if (gaym->session && GAIM_CONNECTION_IS_VALID(gaym->account->gc)) {
        // char *pw_hash;
        char *bio;
        char *thumbnail;
        char *temp = NULL;
        char *temp2 = NULL;
        const char *match;
        const char *result;



	gaym->server_stats=NULL;
	gaym->hash_pw=NULL;
	gaym->server_bioline=NULL;
	gaym->thumbnail=NULL;
	
        // First, look for password
        match = "password\" value=\"";
        temp = strstr(text, match);
        if (temp) {
            temp += strlen(match);
            temp2 = strstr(temp, "\" ");
        }
        if (!
            (temp && temp2 && temp != temp2
             && (gaym->hash_pw =
                 g_strndup(temp, (temp2 - temp) * sizeof(char))))) {
            gaim_connection_error((gaym->account->gc),
                                  _
                                  ("Problem parsing password from web. Report a bug."));
            return;
        }

        gaim_debug_misc("weblogin",
                        "Got hash, temp=%x, temp2=%x, gaym->hash_pw=%x\n",
                        temp, temp2, gaym->hash_pw);
        // Next, loook for bio
        match = "param name=\"bio\" value=\"";
        temp = strstr(text, match);
        if (temp) {
            temp += strlen(match);
            temp2 = strstr(temp, "%23");
        }
        if (temp && temp2) {
            thumbnail = g_strndup(temp, (temp2 - temp) * sizeof(char));
            result = gaym_url_decode(thumbnail);
            (gaym->thumbnail = g_strdup(result))
                || (gaym->thumbnail = g_strdup(" "));

            g_free(thumbnail);
            // Parse out non thumbnail part of bio.
            temp = strstr(temp2, "\"");
            if (temp) {
                bio = g_strndup(temp2, (temp - temp2) * sizeof(char));
                result = gaym_url_decode(bio);
                gaim_debug_info("gaym", "Server BIO: %s Thumb: %s\n",
                                result, gaym->thumbnail);
                (gaym->server_bioline = g_strdup(result))
                    || (gaym->server_bioline = NULL);
                g_free(bio);

		//Parse out stats part of bio.
		temp2 = strchr(result, (char)0x01);
		if(temp2++) {
		    gaim_debug_misc("gaym", "Stats: %s\n", temp2);
		    gaym->server_stats = g_strdup(temp2);
		}
	    }
        } else {
            // gaim_connection_error(
            // gaim_account_get_connection(((struct
            // gaym_conn*)((GaimUrlSession*)session)->account),
            // _("Problem parsing password from web. Report a bug."));
        }
        gaym->session->session_cb(gaym->account);

    } else {
        gaim_debug_misc("gaym", "Connection was cancelled before step5\n");
        gaim_debug_misc("gaym", "gaym->sessoin: %x\n", gaym->session);
    }


}
Ejemplo n.º 20
0
void
msn_message_show_readable(MsnMessage *msg, const char *info,
                          gboolean text_body)
{
    GString *str;
    size_t body_len;
    const char *body;
    GList *l;

    g_return_if_fail(msg != NULL);

    str = g_string_new(NULL);

    /* Standard header. */
    if (msg->charset == NULL)
    {
        g_string_append_printf(str,
                               "MIME-Version: 1.0\r\n"
                               "Content-Type: %s\r\n",
                               msg->content_type);
    }
    else
    {
        g_string_append_printf(str,
                               "MIME-Version: 1.0\r\n"
                               "Content-Type: %s; charset=%s\r\n",
                               msg->content_type, msg->charset);
    }

    for (l = msg->attr_list; l; l = l->next)
    {
        char *key;
        const char *value;

        key = l->data;
        value = msn_message_get_attr(msg, key);

        g_string_append_printf(str, "%s: %s\r\n", key, value);
    }

    g_string_append(str, "\r\n");

    body = msn_message_get_bin_data(msg, &body_len);

    if (msg->msnslp_message)
    {
        g_string_append_printf(str, "Session ID: %u\r\n", msg->msnslp_header.session_id);
        g_string_append_printf(str, "ID:         %u\r\n", msg->msnslp_header.id);
        g_string_append_printf(str, "Offset:     %" G_GUINT64_FORMAT "\r\n", msg->msnslp_header.offset);
        g_string_append_printf(str, "Total size: %" G_GUINT64_FORMAT "\r\n", msg->msnslp_header.total_size);
        g_string_append_printf(str, "Length:     %u\r\n", msg->msnslp_header.length);
        g_string_append_printf(str, "Flags:      0x%x\r\n", msg->msnslp_header.flags);
        g_string_append_printf(str, "ACK ID:     %u\r\n", msg->msnslp_header.ack_id);
        g_string_append_printf(str, "SUB ID:     %u\r\n", msg->msnslp_header.ack_sub_id);
        g_string_append_printf(str, "ACK Size:   %" G_GUINT64_FORMAT "\r\n", msg->msnslp_header.ack_size);

#ifdef MSN_DEBUG_SLP_VERBOSE
        if (body != NULL)
        {
            if (text_body)
            {
                g_string_append_len(str, body, body_len);
                if (body[body_len - 1] == '\0')
                {
                    str->len--;
                    g_string_append(str, " 0x00");
                }
                g_string_append(str, "\r\n");
            }
            else
            {
                int i;
                for (i = 0; i < msg->body_len; i++)
                {
                    g_string_append_printf(str, "%.2hhX ", body[i]);
                    if ((i % 16) == 15)
                        g_string_append(str, "\r\n");
                }
                g_string_append(str, "\r\n");
            }
        }
#endif

        g_string_append_printf(str, "Footer:     %u\r\n", msg->msnslp_footer.value);
    }
    else
    {
        if (body != NULL)
        {
            g_string_append_len(str, body, body_len);
            g_string_append(str, "\r\n");
        }
    }

    gaim_debug_info("msn", "Message %s:\n{%s}\n", info, str->str);

    g_string_free(str, TRUE);
}
Ejemplo n.º 21
0
Archivo: si.c Proyecto: VoxOx/VoxOx
static void
jabber_si_xfer_bytestreams_send_read_again_cb(gpointer data, gint source,
		GaimInputCondition cond)
{
	GaimXfer *xfer = data;
	JabberSIXfer *jsx = xfer->data;
	int i;
	char buffer[256];
	int len;
	char *dstaddr, *p;
	unsigned char hashval[20];
	const char *host;

	gaim_debug_info("jabber", "in jabber_si_xfer_bytestreams_send_read_again_cb\n");

	if(jsx->rxlen < 5) {
		gaim_debug_info("jabber", "reading the first 5 bytes\n");
		len = read(source, buffer, 5 - jsx->rxlen);
		if(len < 0 && errno == EAGAIN)
			return;
		else if(len <= 0) {
			gaim_input_remove(xfer->watcher);
			xfer->watcher = 0;
			close(source);
			gaim_xfer_cancel_remote(xfer);
			return;
		}
		jsx->rxqueue = g_realloc(jsx->rxqueue, len + jsx->rxlen);
		memcpy(jsx->rxqueue + jsx->rxlen, buffer, len);
		jsx->rxlen += len;
		return;
	} else if(jsx->rxqueue[0] != 0x05 || jsx->rxqueue[1] != 0x01 ||
			jsx->rxqueue[3] != 0x03) {
		gaim_debug_info("jabber", "invalid socks5 stuff\n");
		gaim_input_remove(xfer->watcher);
		xfer->watcher = 0;
		close(source);
		gaim_xfer_cancel_remote(xfer);
		return;
	} else if(jsx->rxlen - 5 <  jsx->rxqueue[4] + 2) {
		gaim_debug_info("jabber", "reading umpteen more bytes\n");
		len = read(source, buffer, jsx->rxqueue[4] + 5 + 2 - jsx->rxlen);
		if(len < 0 && errno == EAGAIN)
			return;
		else if(len <= 0) {
			gaim_input_remove(xfer->watcher);
			xfer->watcher = 0;
			close(source);
			gaim_xfer_cancel_remote(xfer);
			return;
		}
		jsx->rxqueue = g_realloc(jsx->rxqueue, len + jsx->rxlen);
		memcpy(jsx->rxqueue + jsx->rxlen, buffer, len);
		jsx->rxlen += len;
	}

	if(jsx->rxlen - 5 < jsx->rxqueue[4] + 2)
		return;

	gaim_input_remove(xfer->watcher);
	xfer->watcher = 0;

	dstaddr = g_strdup_printf("%s%s@%s/%s%s", jsx->stream_id,
			jsx->js->user->node, jsx->js->user->domain,
			jsx->js->user->resource, xfer->who);

	gaim_cipher_digest_region("sha1", (guchar *)dstaddr, strlen(dstaddr),
							  sizeof(hashval), hashval, NULL);
	g_free(dstaddr);
	dstaddr = g_malloc(41);
	p = dstaddr;
	for(i=0; i<20; i++, p+=2)
		snprintf(p, 3, "%02x", hashval[i]);

	if(jsx->rxqueue[4] != 40 || strncmp(dstaddr, jsx->rxqueue+5, 40) ||
			jsx->rxqueue[45] != 0x00 || jsx->rxqueue[46] != 0x00) {
		gaim_debug_error("jabber", "someone connected with the wrong info!\n");
		close(source);
		gaim_xfer_cancel_remote(xfer);
		return;
	}

	g_free(jsx->rxqueue);
	host = gaim_network_get_my_ip(jsx->js->fd);

	jsx->rxmaxlen = 5 + strlen(host) + 2;
	jsx->rxqueue = g_malloc(jsx->rxmaxlen);
	jsx->rxlen = 0;

	jsx->rxqueue[0] = 0x05;
	jsx->rxqueue[1] = 0x00;
	jsx->rxqueue[2] = 0x00;
	jsx->rxqueue[3] = 0x03;
	jsx->rxqueue[4] = strlen(host);
	memcpy(jsx->rxqueue + 5, host, strlen(host));
	jsx->rxqueue[5+strlen(host)] = 0x00;
	jsx->rxqueue[6+strlen(host)] = 0x00;

	xfer->watcher = gaim_input_add(source, GAIM_INPUT_WRITE,
		jabber_si_xfer_bytestreams_send_read_again_resp_cb, xfer);
	jabber_si_xfer_bytestreams_send_read_again_resp_cb(xfer, source,
		GAIM_INPUT_WRITE);
}
Ejemplo n.º 22
0
/**
 * This is our callback for the receiving-im-msg signal.
 *
 * We return TRUE to block the IM, FALSE to accept the IM
 */
static gboolean receiving_im_msg_cb(GaimAccount * account, char **sender,
                                    char **buffer, int *flags, void *data)
{
    gboolean retval = FALSE;    /* assume the sender is allowed */
    gboolean found = FALSE;
    gint pos = -1;
    char *botmsg = NULL;


    PendingMessage *pending = NULL;
    GSList *slist = NULL;
    GSList *search = NULL;

    GaimConnection *connection = NULL;

    /* expire any old entries in pending */
    expire_pending_list();

    connection = gaim_account_get_connection(account);

    /* not good, but don't do anything */
    if (!connection || !sender) {
        return retval;
    }

    /* if there is already an open conversation, allowed it */
    if (gaim_find_conversation_with_account(*sender, account)) {
        return retval;
    }

    /* don't make buddies use the challenge/response system */
    if (gaim_find_buddy(account, *sender)) {
        return retval;
    }

    /* don't make permit list members use the challenge/response system */
    for (slist = account->permit; slist != NULL; slist = slist->next) {
        if (!gaim_utf8_strcasecmp
            (*sender, gaim_normalize(account, (char *) slist->data))) {
            return retval;
        }
    }

    /* if there is no question or no answer, allow the sender */
    const char *question =
        gaim_prefs_get_string("/plugins/core/bot/challenger/question");
    const char *answer =
        gaim_prefs_get_string("/plugins/core/bot/challenger/answer");
    if (!question || !answer) {
        return retval;
    }

    /* blank / null message ... can this even happen? */
    if (!*buffer) {
        return retval;
    }

    /* search if this sender is already in pending */
    for (search = pending_list; search; search = search->next) {
        pending = search->data;
        pos = g_slist_position(pending_list, search);

        if (protocmp(account, pending) && usercmp(account, pending)
            && sendercmp(*sender, pending)) {
            found = TRUE;
            break;
        }
    }

    if (!found) {
        /**
         * its the first time through, save the nick/msg to the
         * queue and ask the question
         */
        GTimeVal *now = NULL;
        now = g_new0(GTimeVal, 1);
        g_get_current_time(now);
        PendingMessage *newpend = NULL;

        newpend = g_new0(PendingMessage, 1);
        newpend->tv_sec = now->tv_sec;
        newpend->protocol = g_strdup(account->protocol_id);
        newpend->username = g_strdup(account->username);
        newpend->sender = g_strdup(*sender);
        newpend->message = g_strdup(*buffer);
        pending_list = g_slist_append(pending_list, newpend);

        botmsg =
            g_strdup_printf(_
                            ("Bot Challenger engaged:  you are now being ignored!  Your message will be delivered if you can correctly answer the following question within %i minutes:  %s"),
                            BOT_MAX_MINUTES, question);
        send_auto_reply(account, *sender, botmsg);

        g_free(now);
        g_free(botmsg);
        retval = TRUE;
    } else {
        if (gaim_utf8_strcasecmp(*buffer, answer)) {
                /**
                 * Sorry, thanks for playing, please try again
                 */
            retval = TRUE;
        } else {
            botmsg =
                _
                ("Bot Challenger accepted your answer and delivered your original message.  You may now speak freely.");
            send_auto_reply(account, *sender, botmsg);

            if (gaim_prefs_get_bool
                ("/plugins/core/bot/challenger/auto_add_permit")) {
                if (!gaim_privacy_permit_add(account, *sender, FALSE)) {
                    gaim_debug_info("bot-challenger",
                                    "Unable to add %s/%s/%s to permit list\n",
                                    *sender, pending->username,
                                    pending->protocol);
                }
            }

            /**
             * Free what is currently in the buffer (the correct answer)
             * and replace it with the user's first message that was
             * queued, pending the correct answer.  I think some other
             * process is supposed to free the buffer after its sent.
             */
            g_free(*buffer);
            *buffer = pending->message;

            /* Clean up everything else except pending->message */
            free_pending(search, FALSE);

            retval = FALSE;     /* Don't block this message */
        }
    }
    debug_pending_list();
    return retval;              /* returning TRUE will block the IM */
}
Ejemplo n.º 23
0
static void
read_cb(gpointer data, gint source, GaimInputCondition cond)
{
	MsnDirectConn* directconn;
	char *body;
	size_t len, body_len;

	gaim_debug_info("msn", "read_cb: %d, %d\n", source, cond);

	directconn = data;

	/* Let's read the length of the data. */
	len = read(directconn->fd, &body_len, sizeof(body_len));

	if (len <= 0)
	{
		/* ERROR */
		gaim_debug_error("msn", "error reading\n");

		msn_directconn_destroy(directconn);

		return;
	}

	body_len = GUINT32_FROM_LE(body_len);

	gaim_debug_info("msn", "body_len=%d\n", body_len);

	if (body_len <= 0)
	{
		/* ERROR */
		gaim_debug_error("msn", "error reading\n");

		msn_directconn_destroy(directconn);

		return;
	}

	body = g_try_malloc(body_len);

	if (body != NULL)
	{
		/* Let's read the data. */
		len = read(directconn->fd, body, body_len);

		gaim_debug_info("msn", "len=%d\n", len);
	}
	else
	{
		gaim_debug_error("msn", "Failed to allocate memory for read\n");
		len = 0;
	}

	if (len > 0)
	{
		MsnMessage *msg;

#ifdef DEBUG_DC
		str = g_strdup_printf("/home/revo/msntest/r%.4d.bin", directconn->c);

		FILE *tf = g_fopen(str, "w");
		fwrite(body, 1, len, tf);
		fclose(tf);

		g_free(str);
#endif

		directconn->c++;

		msg = msn_message_new_msnslp();
		msn_message_parse_slp_body(msg, body, body_len);

		msn_directconn_process_msg(directconn, msg);
	}
	else
	{
		/* ERROR */
		gaim_debug_error("msn", "error reading\n");

		msn_directconn_destroy(directconn);
	}
}
Ejemplo n.º 24
0
static void
gaym_weblogin_step5(GaimUtilFetchUrlData *url_data, gpointer data, const gchar *text, gsize len, const gchar* err)
{
    gaim_debug_misc("weblogin","STEP FIVE BEGINS\n"); 
    GaimUrlSession *session = (GaimUrlSession *) data;
    struct gaym_conn *gaym = session->gaym;
    // Get hash from text
    if (session && GAIM_CONNECTION_IS_VALID(session->account->gc)) {
        char *bio;
        char *thumbnail;
        char *temp = NULL;
        char *temp2 = NULL;
        const char *match;
        const char *result;



        gaym->server_stats = NULL;
        gaym->chat_key = NULL;
        gaym->server_bioline = NULL;
        gaym->thumbnail = NULL;

        // First, look for password
        match = "password\" value=\"";
        temp = strstr(text, match);
        if (temp) {
            temp += strlen(match);
            temp2 = strstr(temp, "\" ");
        }
        if (!
            (temp && temp2 && temp != temp2
             && (gaym->chat_key =
                 g_strndup(temp, (temp2 - temp) * sizeof(char))))) {
            gaim_connection_error((session->account->gc),
                                  _
                                  ("Problem parsing password from web. Report a bug."));
            return;
        }

        gaim_debug_misc("weblogin",
                        "Got hash, temp=%x, temp2=%x, gaym->chat_key=%x\n",
                        temp, temp2, gaym->chat_key);
        // Next, loook for bio
        match = "param name=\"bio\" value=\"";
        temp = strstr(text, match);
        if (temp) {
            temp += strlen(match);
            temp2 = strstr(temp, "%23");
        }
        if (temp && temp2) {
            thumbnail = g_strndup(temp, (temp2 - temp) * sizeof(char));
            result = gaym_url_decode(thumbnail);
            (gaym->thumbnail = g_strdup(result))
                || (gaym->thumbnail = g_strdup(" "));

            g_free(thumbnail);
            // Parse out non thumbnail part of bio.
            temp = strstr(temp2, "\"");
            if (temp) {
                bio = g_strndup(temp2, (temp - temp2) * sizeof(char));
                result = gaym_url_decode(bio);
                gaim_debug_info("gaym", "Server BIO: %s Thumb: %s\n",
                                result, gaym->thumbnail);
                (gaym->server_bioline = g_strdup(result))
                    || (gaym->server_bioline = NULL);
                g_free(bio);

                // Parse out stats part of bio.
                temp2 = strchr(result, (char) 0x01);
                if (temp2++) {
                    gaim_debug_misc("gaym", "Stats: %s\n", temp2);
                    gaym->server_stats = g_strdup(temp2);
                }
            }
        } else {
            // gaim_connection_error(
            // gaim_account_get_connection(((struct
            // gaym_conn*)((GaimUrlSession*)session)->account),
            // _("Problem parsing password from web. Report a bug.")));
        }
        session->session_cb(gaym->account);

    } else {
        gaim_debug_misc("gaym", "Connection was cancelled before step5\n");
        gaim_debug_misc("gaym", "gaym->session: %x\n", session);
    }

    // We don't need the session info anymore.
    gaym_session_destroy(session);

}
Ejemplo n.º 25
0
Archivo: si.c Proyecto: VoxOx/VoxOx
static void
jabber_si_xfer_bytestreams_send_read_cb(gpointer data, gint source,
		GaimInputCondition cond)
{
	GaimXfer *xfer = data;
	JabberSIXfer *jsx = xfer->data;
	int i;
	int len;
	char buffer[256];

	gaim_debug_info("jabber", "in jabber_si_xfer_bytestreams_send_read_cb\n");

	xfer->fd = source;

	if(jsx->rxlen < 2) {
		gaim_debug_info("jabber", "reading those first two bytes\n");
		len = read(source, buffer, 2 - jsx->rxlen);
		if(len < 0 && errno == EAGAIN)
			return;
		else if(len <= 0) {
			gaim_input_remove(xfer->watcher);
			xfer->watcher = 0;
			close(source);
			gaim_xfer_cancel_remote(xfer);
			return;
		}
		jsx->rxqueue = g_realloc(jsx->rxqueue, len + jsx->rxlen);
		memcpy(jsx->rxqueue + jsx->rxlen, buffer, len);
		jsx->rxlen += len;
		return;
	} else if(jsx->rxlen - 2 <  jsx->rxqueue[1]) {
		gaim_debug_info("jabber", "reading the next umpteen bytes\n");
		len = read(source, buffer, jsx->rxqueue[1] + 2 - jsx->rxlen);
		if(len < 0 && errno == EAGAIN)
			return;
		else if(len <= 0) {
			gaim_input_remove(xfer->watcher);
			xfer->watcher = 0;
			close(source);
			gaim_xfer_cancel_remote(xfer);
			return;
		}
		jsx->rxqueue = g_realloc(jsx->rxqueue, len + jsx->rxlen);
		memcpy(jsx->rxqueue + jsx->rxlen, buffer, len);
		jsx->rxlen += len;
	}

	if(jsx->rxlen -2 < jsx->rxqueue[1])
		return;

	gaim_input_remove(xfer->watcher);
	xfer->watcher = 0;

	gaim_debug_info("jabber", "checking to make sure we're socks FIVE\n");

	if(jsx->rxqueue[0] != 0x05) {
		close(source);
		gaim_xfer_cancel_remote(xfer);
		return;
	}

	gaim_debug_info("jabber", "going to test %hhu different methods\n", jsx->rxqueue[1]);

	for(i=0; i<jsx->rxqueue[1]; i++) {

		gaim_debug_info("jabber", "testing %hhu\n", jsx->rxqueue[i+2]);
		if(jsx->rxqueue[i+2] == 0x00) {
			g_free(jsx->rxqueue);
			jsx->rxlen = 0;
			jsx->rxmaxlen = 2;
			jsx->rxqueue = g_malloc(jsx->rxmaxlen);
			jsx->rxqueue[0] = 0x05;
			jsx->rxqueue[1] = 0x00;
			xfer->watcher = gaim_input_add(source, GAIM_INPUT_WRITE,
				jabber_si_xfer_bytestreams_send_read_response_cb,
				xfer);
			jabber_si_xfer_bytestreams_send_read_response_cb(xfer,
				source, GAIM_INPUT_WRITE);
			jsx->rxqueue = NULL;
			jsx->rxlen = 0;
			return;
		}
	}

	g_free(jsx->rxqueue);
	jsx->rxlen = 0;
	jsx->rxmaxlen = 2;
	jsx->rxqueue = g_malloc(jsx->rxmaxlen);
	jsx->rxqueue[0] = 0x05;
	jsx->rxqueue[1] = 0xFF;
	xfer->watcher = gaim_input_add(source, GAIM_INPUT_WRITE,
		jabber_si_xfer_bytestreams_send_read_response_cb, xfer);
	jabber_si_xfer_bytestreams_send_read_response_cb(xfer,
		source, GAIM_INPUT_WRITE);
}
Ejemplo n.º 26
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;
}
Ejemplo n.º 27
0
void
gaim_connection_destroy(GaimConnection *gc)
{
	GaimAccount *account;
	GSList *buddies, *tmp;
#if 0
	GList *wins;
#endif
	GaimPluginProtocolInfo *prpl_info = NULL;
	gboolean remove = FALSE;

	g_return_if_fail(gc != NULL);

	account = gaim_connection_get_account(gc);

	gaim_debug_info("connection", "Disconnecting connection %p\n", gc);

	if (gaim_connection_get_state(gc) != GAIM_CONNECTING)
		remove = TRUE;

	gaim_signal_emit(gaim_connections_get_handle(), "signing-off", gc);

	while (gc->buddy_chats)
	{
		GaimConversation *b = gc->buddy_chats->data;

		gc->buddy_chats = g_slist_remove(gc->buddy_chats, b);
		gaim_conv_chat_left(GAIM_CONV_CHAT(b));
	}

	update_keepalive(gc, FALSE);

	gaim_proxy_connect_cancel_with_handle(gc);

	prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
	if (prpl_info->close)
		(prpl_info->close)(gc);

	/* Clear out the proto data that was freed in the prpl close method*/
	buddies = gaim_find_buddies(account, NULL);
	for (tmp = buddies; tmp; tmp = tmp->next) {
		GaimBuddy *buddy = tmp->data;
		buddy->proto_data = NULL;
	}
	g_slist_free(buddies);

	connections = g_list_remove(connections, gc);

	gaim_connection_set_state(gc, GAIM_DISCONNECTED);

	if (remove)
		gaim_blist_remove_account(account);

	gaim_signal_emit(gaim_connections_get_handle(), "signed-off", gc);

#if 0
	/* see comment later in file on if 0'd same code */
	/*
	 * 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) {
		GaimConvWindow *win = (GaimConvWindow *)wins->data;
		gaim_conversation_update(gaim_conv_window_get_conversation_at(win, 0),
								 GAIM_CONV_ACCOUNT_OFFLINE);
	}
#endif

	gaim_request_close_with_handle(gc);
	gaim_notify_close_with_handle(gc);

	gaim_debug_info("connection", "Destroying connection %p\n", gc);

	gaim_account_set_connection(account, NULL);

	g_free(gc->password);
	g_free(gc->display_name);

	if (gc->disconnect_timeout)
		gaim_timeout_remove(gc->disconnect_timeout);

	GAIM_DBUS_UNREGISTER_POINTER(gc);
	g_free(gc);
}