コード例 #1
0
ファイル: irc.c プロジェクト: VoxOx/VoxOx
static void irc_input_cb_ssl(gpointer data, GaimSslConnection *gsc,
		GaimInputCondition cond)
{

	GaimConnection *gc = data;
	struct irc_conn *irc = gc->proto_data;
	int len;

	if(!g_list_find(gaim_connections_get_all(), gc)) {
		gaim_ssl_close(gsc);
		return;
	}

	if (irc->inbuflen < irc->inbufused + IRC_INITIAL_BUFSIZE) {
		irc->inbuflen += IRC_INITIAL_BUFSIZE;
		irc->inbuf = g_realloc(irc->inbuf, irc->inbuflen);
	}

	len = gaim_ssl_read(gsc, irc->inbuf + irc->inbufused, IRC_INITIAL_BUFSIZE - 1);

	if (len < 0 && errno == EAGAIN) {
		/* Try again later */
		return;
	} else if (len < 0) {
		gaim_connection_error(gc, _("Read error"));
		return;
	} else if (len == 0) {
		gaim_connection_error(gc, _("Server has disconnected"));
		return;
	}

	read_input(irc, len);
}
コード例 #2
0
ファイル: irc.c プロジェクト: VoxOx/VoxOx
static void irc_login(GaimAccount *account)
{
	GaimConnection *gc;
	struct irc_conn *irc;
	char **userparts;
	const char *username = gaim_account_get_username(account);

	gc = gaim_account_get_connection(account);
	gc->flags |= GAIM_CONNECTION_NO_NEWLINES;

	if (strpbrk(username, " \t\v\r\n") != NULL) {
		gaim_connection_error(gc, _("IRC nicks may not contain whitespace"));
		return;
	}

	gc->proto_data = irc = g_new0(struct irc_conn, 1);
	irc->fd = -1;
	irc->account = account;
	irc->outbuf = gaim_circ_buffer_new(512);

	userparts = g_strsplit(username, "@", 2);
	gaim_connection_set_display_name(gc, userparts[0]);
	irc->server = g_strdup(userparts[1]);
	g_strfreev(userparts);

	irc->buddies = g_hash_table_new_full((GHashFunc)irc_nick_hash, (GEqualFunc)irc_nick_equal,
					     NULL, (GDestroyNotify)irc_buddy_free);
	irc->cmds = g_hash_table_new(g_str_hash, g_str_equal);
	irc_cmd_table_build(irc);
	irc->msgs = g_hash_table_new(g_str_hash, g_str_equal);
	irc_msg_table_build(irc);

	gaim_connection_update_progress(gc, _("Connecting"), 1, 2);

	if (gaim_account_get_bool(account, "ssl", FALSE)) {
		if (gaim_ssl_is_supported()) {
			irc->gsc = gaim_ssl_connect(account, irc->server,
					gaim_account_get_int(account, "port", IRC_DEFAULT_SSL_PORT),
					irc_login_cb_ssl, irc_ssl_connect_failure, gc);
		} else {
			gaim_connection_error(gc, _("SSL support unavailable"));
			return;
		}
	}

	if (!irc->gsc) {

		if (gaim_proxy_connect(gc, account, irc->server,
				 gaim_account_get_int(account, "port", IRC_DEFAULT_PORT),
				 irc_login_cb, gc) == NULL)
		{
			gaim_connection_error(gc, _("Couldn't create socket"));
			return;
		}
	}
}
コード例 #3
0
ファイル: gaym.c プロジェクト: BackupTheBerlios/qrc-svn
static void gaym_login_with_chat_key(GaimAccount * account)
{
    GaimConnection *gc;
    struct gaym_conn *gaym;
    char *buf;
    const char *username = gaim_account_get_username(account);
    int err;

    gc = gaim_account_get_connection(account);
    gaym = gc->proto_data;

    buf = g_strdup_printf(_("Signon: %s"), username);
    gaim_connection_update_progress(gc, buf, 5, 6);
    g_free(buf);
    gaim_debug_misc("gaym", "Trying login to %s\n", gaym->server);
    err = gaim_proxy_connect(account, gaym->server,
                             gaim_account_get_int(account, "port",
                                                  IRC_DEFAULT_PORT),
                             gaym_login_cb, gc);
    if (err || !account->gc) {
        gaim_connection_error(gc, _("Couldn't create socket"));
        gaim_debug_misc("gaym", "err: %d, account->gc: %x\n", err,
                        account->gc);
        return;
    }

}
コード例 #4
0
ファイル: yahoo_packet.c プロジェクト: VoxOx/VoxOx
static void
yahoo_packet_send_can_write(gpointer data, gint source, GaimInputCondition cond)
{
	struct yahoo_data *yd = data;
	int ret, writelen;

	writelen = gaim_circ_buffer_get_max_read(yd->txbuf);

	if (writelen == 0) {
		gaim_input_remove(yd->txhandler);
		yd->txhandler = -1;
		return;
	}

	ret = write(yd->fd, yd->txbuf->outptr, writelen);

	if (ret < 0 && errno == EAGAIN)
		return;
	else if (ret < 0) {
		/* TODO: what to do here - do we really have to disconnect? */
		gaim_connection_error(yd->gc, _("Write Error"));
		return;
	}

	gaim_circ_buffer_mark_read(yd->txbuf, ret);
}
コード例 #5
0
ファイル: keep_alive.c プロジェクト: VoxOx/VoxOx
/* 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);
}
コード例 #6
0
ファイル: simple.c プロジェクト: HolgerJahnel/resiprocate
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);
  }
コード例 #7
0
ファイル: irc.c プロジェクト: VoxOx/VoxOx
static void
irc_send_cb(gpointer data, gint source, GaimInputCondition cond)
{
	struct irc_conn *irc = data;
	int ret, writelen;

	writelen = gaim_circ_buffer_get_max_read(irc->outbuf);

	if (writelen == 0) {
		gaim_input_remove(irc->writeh);
		irc->writeh = 0;
		return;
	}

	ret = do_send(irc, irc->outbuf->outptr, writelen);

	if (ret < 0 && errno == EAGAIN)
		return;
	else if (ret <= 0) {
		gaim_connection_error(gaim_account_get_connection(irc->account),
			      _("Server has disconnected"));
		return;
	}

	gaim_circ_buffer_mark_read(irc->outbuf, ret);

#if 0
	/* We *could* try to write more if we wrote it all */
	if (ret == write_len) {
		irc_send_cb(data, source, cond);
	}
#endif
}
コード例 #8
0
ファイル: irc.c プロジェクト: VoxOx/VoxOx
static void
irc_ssl_connect_failure(GaimSslConnection *gsc, GaimSslErrorType error,
		gpointer data)
{
	GaimConnection *gc = data;
	struct irc_conn *irc = gc->proto_data;

	irc->gsc = NULL;

	switch(error) {
		case GAIM_SSL_CONNECT_FAILED:
			gaim_connection_error(gc, _("Connection Failed"));
			break;
		case GAIM_SSL_HANDSHAKE_FAILED:
			gaim_connection_error(gc, _("SSL Handshake Failed"));
			break;
	}
}
コード例 #9
0
ファイル: gaym.c プロジェクト: BackupTheBerlios/qrc-svn
static void gaym_input_cb(gpointer data, gint source,
                          GaimInputCondition cond)
{
    GaimConnection *gc = data;
    struct gaym_conn *gaym = gc->proto_data;
    char *cur, *end;
    int len;

    if (gaym->inbuflen < gaym->inbufused + IRC_INITIAL_BUFSIZE) {
        gaym->inbuflen += IRC_INITIAL_BUFSIZE;
        gaym->inbuf = g_realloc(gaym->inbuf, gaym->inbuflen);
    }

    if ((len =
         read(gaym->fd, gaym->inbuf + gaym->inbufused,
              IRC_INITIAL_BUFSIZE - 1)) < 0) {
        gaim_connection_error(gc, _("Read error"));
        return;
    } else if (len == 0) {
        gaim_connection_error(gc, _("Server has disconnected"));
        return;
    }

    gaym->inbufused += len;
    gaym->inbuf[gaym->inbufused] = '\0';

    cur = gaym->inbuf;
    while (cur < gaym->inbuf + gaym->inbufused &&
           ((end = strstr(cur, "\r\n")) || (end = strstr(cur, "\n")))) {
        int step = (*end == '\r' ? 2 : 1);
        *end = '\0';
        gaym_parse_msg(gaym, cur);
        cur = end + step;
    }
    if (cur != gaym->inbuf + gaym->inbufused) { /* leftover */
        gaym->inbufused -= (cur - gaym->inbuf);
        memmove(gaym->inbuf, cur, gaym->inbufused);
    } else {
        gaym->inbufused = 0;
    }
}
コード例 #10
0
ファイル: gaym.c プロジェクト: BackupTheBerlios/qrc-svn
int gaym_send(struct gaym_conn *gaym, const char *buf)
{
    int ret;

    if (gaym->fd < 0)
        return -1;

    /* gaim_debug(GAIM_DEBUG_MISC, "gaym", "sent: %s", buf); */
    if ((ret = write(gaym->fd, buf, strlen(buf))) < 0)
        gaim_connection_error(gaim_account_get_connection(gaym->account),
                              _("Server has disconnected"));

    return ret;
}
コード例 #11
0
ファイル: irc.c プロジェクト: VoxOx/VoxOx
static void irc_input_cb(gpointer data, gint source, GaimInputCondition cond)
{
	GaimConnection *gc = data;
	struct irc_conn *irc = gc->proto_data;
	int len;

	if (irc->inbuflen < irc->inbufused + IRC_INITIAL_BUFSIZE) {
		irc->inbuflen += IRC_INITIAL_BUFSIZE;
		irc->inbuf = g_realloc(irc->inbuf, irc->inbuflen);
	}

	len = read(irc->fd, irc->inbuf + irc->inbufused, IRC_INITIAL_BUFSIZE - 1);
	if (len < 0 && errno == EAGAIN) {
		return;
	} else if (len < 0) {
		gaim_connection_error(gc, _("Read error"));
		return;
	} else if (len == 0) {
		gaim_connection_error(gc, _("Server has disconnected"));
		return;
	}

	read_input(irc, len);
}
コード例 #12
0
ファイル: irc.c プロジェクト: VoxOx/VoxOx
static void irc_login_cb(gpointer data, gint source, const gchar *error_message)
{
	GaimConnection *gc = data;
	struct irc_conn *irc = gc->proto_data;

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

	irc->fd = source;

	if (do_login(gc)) {
		gc->inpa = gaim_input_add(irc->fd, GAIM_INPUT_READ, irc_input_cb, gc);
	}
}
コード例 #13
0
ファイル: weblogin.c プロジェクト: BackupTheBerlios/qrc-svn
static void
gaym_weblogin_step3(gpointer data, const char *text, size_t len)
{




    struct gaym_conn *gaym = (struct gaym_conn *) data;

    gaim_debug_misc("gaym", "Step 3: gaym->sessoin: %x\n", gaym->session);
    if (gaym && gaym->session
        && GAIM_CONNECTION_IS_VALID(gaym->session->account->gc)) {
        if (!strstr(gaym->session->cookies, "MEMBERX")) {
            g_free(gaym->session);
            gaim_connection_error((gaym->account->gc),
                                  _
                                  ("Problem during login. Are you sure your password is correct?"));
            return;
        }
        // The third step is to get a nonce needed for getting the applet.
        // We connect to messenger/frameset.html, using previously set
        // cookie values.
        // From the returned body, we will need to parse out the rand
        // values.
        char *url = "http://www.gay.com/messenger/frameset.html";
        char *buf = g_strdup_printf(_("Signon: %s"),
                                    (gaym->session->account->username));
        gaim_connection_update_progress(gaym->session->account->gc, buf, 4,
                                        6);
        gaym->session->hasFormData = FALSE;
        gaim_session_fetch(url, FALSE, NULL, FALSE, gaym_weblogin_step4,
                           gaym, gaym->session);
    } else {

        gaim_debug_misc("gaym", "Connection was cancelled before step3\n");
        gaim_debug_misc("gaym", "gaym->sessoin: %x\n", gaym->session);
        // g_free(gaym->session);

    }
}
コード例 #14
0
static void
save_profile_cb(GaimConnection *gc, GaimRequestFields *fields)
{
	TrepiaSession *session = gc->proto_data;
	const char *value;
	char *buf, *temp;
	int int_val;

	buf = g_strdup("<K>");
	temp = buf;

	SET_STRING_FIELD("b", "email");
	SET_STRING_FIELD("c", "homepage");
	SET_STRING_FIELD("d", "firstname");
	SET_STRING_FIELD("e", "lastname");
	SET_STRING_FIELD("f", "icq");
	SET_STRING_FIELD("g", "aim");
	SET_STRING_FIELD("h", "msn");
	SET_STRING_FIELD("i", "yahoo");
	SET_INT_FIELD(   "j", "age");

	int_val = gaim_request_fields_get_choice(fields, "gender");

	buf = g_strdup_printf("%s<k>%c</k>", temp, (int_val == 1 ? 'F' : 'M'));
	g_free(temp);
	temp = buf;

	SET_STRING_FIELD("l", "profile");
	SET_STRING_FIELD("n", "country");
	SET_STRING_FIELD("o", "state");
	SET_STRING_FIELD("p", "city");

	buf = g_strdup_printf("%s</K>", temp);

	if (trepia_write(session->fd, buf, strlen(buf)) < 0) {
		gaim_connection_error(session->gc, _("Write error"));
		return;
	}
}
コード例 #15
0
ファイル: irc.c プロジェクト: VoxOx/VoxOx
int irc_send(struct irc_conn *irc, const char *buf)
{
	int ret, buflen;
 	char *tosend= g_strdup(buf);

	gaim_signal_emit(_irc_plugin, "irc-sending-text", gaim_account_get_connection(irc->account), &tosend);
	if (tosend == NULL)
		return 0;
	
	buflen = strlen(tosend);
	
	
	/* If we're not buffering writes, try to send immediately */
	if (!irc->writeh)
		ret = do_send(irc, tosend, buflen);
	else {
		ret = -1;
		errno = EAGAIN;
	}

	/* gaim_debug(GAIM_DEBUG_MISC, "irc", "sent%s: %s",
		irc->gsc ? " (ssl)" : "", tosend); */
	if (ret <= 0 && errno != EAGAIN) {
		gaim_connection_error(gaim_account_get_connection(irc->account),
				      _("Server has disconnected"));
	} else if (ret < buflen) {
		if (ret < 0)
			ret = 0;
		if (!irc->writeh)
			irc->writeh = gaim_input_add(
				irc->gsc ? irc->gsc->fd : irc->fd,
				GAIM_INPUT_WRITE, irc_send_cb, irc);
		gaim_circ_buffer_append(irc->outbuf, tosend + ret,
			buflen - ret);
	}
	g_free(tosend);
	return ret;
}
コード例 #16
0
ファイル: gaym.c プロジェクト: BackupTheBerlios/qrc-svn
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);


    }
}
コード例 #17
0
ファイル: weblogin.c プロジェクト: BackupTheBerlios/qrc-svn
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);
    }


}
コード例 #18
0
ファイル: simple.c プロジェクト: HolgerJahnel/resiprocate
static void
init_gag(GaimConnection *gc)
{
  char sanity_check_buffer[8];
  int sane;
#ifdef NO_FORK
  char gag_path[256];
  DWORD gag_path_size = 240;
#endif

  gaim_debug(GAIM_DEBUG_INFO,"sippy","Initializing Gag\n");  

#ifdef NO_FORK
  {
    int listenfd;
    int status;
    int shell_exec_status;
    struct sockaddr_in us;
    struct sockaddr_in them;
    size_t addr_len = sizeof(them);
    char buffer[1024];

    memset((void *)&us, 0, sizeof(struct sockaddr_in));
    memset((void *)&them, 0, sizeof(struct sockaddr_in));
    us.sin_family = AF_INET;
    us.sin_port = 0xBEEF;
    inet_aton("127.0.0.1", &(us.sin_addr));

    listenfd = socket(PF_INET, SOCK_STREAM, 0);
    if (listenfd < 0)
    {
      /* We're single threaded, so strerror is safe */
      snprintf(buffer, sizeof(buffer), 
               "Unable to start the SIP engine - "
               "Could not create loopback socket; err = %d (%s)",
               errno, strerror(errno));

      gaim_connection_error(gc, buffer);
      return;
    }

    status = bind (listenfd, (struct sockaddr*)&us, sizeof(struct sockaddr));
    if (status != 0)
    {
      /* We're single threaded, so strerror is safe */
      snprintf(buffer, sizeof(buffer), 
               "Unable to start the SIP engine - "
               "Could not bind to loopback socket; err = %d (%s)",
               errno, strerror(errno));

      gaim_connection_error(gc, buffer);
      return;
    }
 
    status = listen(listenfd, 1);
    if (status != 0)
    {
      /* We're single threaded, so strerror is safe */
      snprintf(buffer, sizeof(buffer), 
               "Unable to start the SIP engine - "
               "Could not listen on loopback socket; err = %d (%s)",
               errno, strerror(errno));

      gaim_connection_error(gc, buffer);
      return;
    }

    /* Start SIP engine */

    /* First, check in the directory into which Gaim is installed */
    SHRegGetUSValue ("SOFTWARE\\gaim", NULL, NULL, 
                     (LPVOID)gag_path, 
                     &gag_path_size, 
                     TRUE,
                     NULL, 0);
    strcat(gag_path, "\\gag.exe");

    shell_exec_status = 
      (int)ShellExecute(NULL, "open", gag_path, "-l", NULL, 0);

    /* If that fails, see if it's in the path somewhere. */
    if (shell_exec_status <= 32)
    {
      shell_exec_status = 
        (int)ShellExecute(NULL, "open", "gag.exe", "-l", NULL, 0);
    }

    /* Well, if we can't find the gag.exe binary, we can't continue. */
    if (shell_exec_status <= 32)
    {
      gaim_connection_error(gc,
         _("Unable to start the SIP engine - gag.exe is not in your path"));
      close(listenfd);
      return;
    }

    gagfd = accept(listenfd, (struct sockaddr *)&them, &addr_len);
    if (gagfd < 0)
    {
      gaim_connection_error(gc,
         _("Unable to start the SIP engine - "
           "Could not accept incoming loopback connection"));
      close(listenfd);
      return;
    }

    close (listenfd);
  }
#else
  {
    int fork_result;

    if ( (pipe(gaimtogag)!=0) || (pipe(gagtogaim)!=0) )
    {
      gaim_connection_error(gc,
         _("Unable to start the SIP engine - resources unavailable"));
      return;
    }
    
    if ( (fork_result = fork()) == -1 )
    {
      gaim_connection_error(gc,
         _("Unable to start the SIP engine - process unavailable"));
      return;
    }
 
    if (fork_result == 0)
    {
      /* We are the child
         Read from gaim using gaimtogag[0]
         Write to gaim using gagtogaim[1]
      */

      close(0);
      close(1);

      dup(gaimtogag[0]);  /* new 0 */
      close(gaimtogag[0]);
      close(gaimtogag[1]);

      dup(gagtogaim[1]);  /* new 1 */
      close(gagtogaim[0]);
      close(gagtogaim[1]);
    
      execlp("gag","gag", (char*)0);

      /* if we're here, exec went horribly wrong */
      { 
        int t,l;
        char v;
        t=2; l=1; v=0;
        write (1,(void *)&t,sizeof(int));
        write (1,(void *)&l,sizeof(int));
        write (1,(void *)&v,1);
      }
      _exit(-1);
    }
  }
#endif

  /* In the parent
     Read from gag using FD_GAG_TO_GAIM
     Write to gag using FD_GAIM_TO_GAG
  */
    
  gaim_debug(GAIM_DEBUG_INFO,"sippy","starting sanity check\n");  
  sane = 1;
  read(FD_GAG_TO_GAIM,sanity_check_buffer,sizeof(int));
  sane = (*((int*)sanity_check_buffer)==2);
  if (sane) {
    read(FD_GAG_TO_GAIM,sanity_check_buffer,sizeof(int));
    sane = (*((int*)sanity_check_buffer)==1);
  }
  if (sane) {
    read(FD_GAG_TO_GAIM,sanity_check_buffer,1);
    sane = ((*sanity_check_buffer)!=0x00);
  }
  
  if (!sane)
  {
    return;
  }

  gaim_debug(GAIM_DEBUG_INFO,"sippy","gag is sane\n");  

  gaginitialized = 1;
}
コード例 #19
0
ファイル: simple.c プロジェクト: HolgerJahnel/resiprocate
static void
sippy_recv_cb(gpointer data, gint source, GaimInputCondition condition)
{
  GaimConnection *gc = data;
  int len;
  int command;
  static char buf[4096];
  static char bufFrom[4096];
  static char bufTo[4096];
  
  len = read( FD_GAG_TO_GAIM, &command, sizeof(command ) );
  if ( len == -1 )
  {
     int err = errno;
     gaim_debug(GAIM_DEBUG_INFO,"sippy","err=%d\n",err);  
     /* something really bad happened */
     resip_assert(0);
  }
  if ( len == 0 )
  {
     /* not ready */
     return;
  }
  resip_assert( len == sizeof(command) );
  
  switch ( command )
  {
     case SIMPLE_IM:
     {	
        gaim_debug(GAIM_DEBUG_INFO,"sippy","got an IM messages from gag\n");  

        sippy_get_string( bufTo, sizeof(bufTo) );
        sippy_get_string( bufFrom, sizeof(bufFrom) );
        sippy_get_string( buf, sizeof(buf) );

        gaim_debug(GAIM_DEBUG_INFO,"sippy","got an IM from=%s to=%s data=%s\n",bufFrom,bufTo,buf);  

        serv_got_im(gc,bufFrom,buf,0,time(NULL)); 
     }
     break;
     
     case SIMPLE_LOGIN_STATUS:
     {
        unsigned char success;
        int sipCode;
        
        /* bool success, int sipCode, data message */
        sippy_get_bool( &success );
        sippy_get_int( &sipCode );
        sippy_get_string( buf, sizeof(buf) );  
 
        gaim_debug(GAIM_DEBUG_INFO,"sippy","got a LOGIN_STATUS status=%d msg=%s\n",sipCode,buf);
	if (gaim_connection_get_state(gc) != GAIM_CONNECTED)
	{
          if (success)
          {
            gaim_connection_update_progress(gc,_("Connecting"),1,2);
            gaim_connection_set_state(gc, GAIM_CONNECTED);
          }
          else
          {
            gaim_connection_error(gc, _(buf));
          }
	}
     }
     break;
     
     case SIMPLE_PRESENCE: /* uri aor, bool  available, Data status */
     { 
        unsigned char open;
	int lastReportedUCStatus;
        
        gaim_debug(GAIM_DEBUG_INFO,"sippy","got a PRES messages from gag\n");

        sippy_get_string( bufFrom, sizeof(bufFrom) );
        sippy_get_bool( &open );
        sippy_get_string( buf, sizeof(buf) );
        
        gaim_debug(GAIM_DEBUG_INFO,"sippy","got a PRES messages from gag from=%s open=%d, msg=%s\n",bufFrom,open,buf);

        {
	  struct simple_connection_cache *sc_cache = gc->proto_data;
	  struct simple_friend_cache *sf;
	  
	  sf = g_hash_table_lookup(sc_cache->friends,bufFrom);
	  if (!sf) {
	    sf = simple_friend_cache_new();
	    g_hash_table_insert(sc_cache->friends,g_strdup(bufFrom),sf);
	  }
          if (sf->status_string)
	  {
	    g_free(sf->status_string);
	  } 
	  sf->status_string = g_strdup(buf);

	  lastReportedUCStatus = (sf->status_int ^= 2);
	} 

	/* AFAICT, there is a half-done change to the use of
	 * the last argument to serv_got_update that is messing
	 * up Yahoo as well as us. The code above the prpl abstraction
	 * claims the integer is ours to do with as we please, but they
	 * use the lowest order bit to mean available or not.
	 *
	 * Other code looks for changes to this integer - if it has
	 * not changed it shortcuts all the GUI updates. So...
	 * We're going to game gaim for now by toggling the second
	 * lowest order bit each time we call this function.
         *
         * TODO: This was true in the gaim 0.71 code - need to review to
         * see if this is still appropriate.
	 */

        serv_got_update(gc, bufFrom, (int)open, 0, 0, 0, lastReportedUCStatus);

     }
     break;
     
     case SIMPLE_HELLO: /* bool ok */
     {
        unsigned char ok;
        sippy_get_bool( &ok ); 
        gaim_debug(GAIM_DEBUG_INFO,"sippy","got a HELLO ok=%d\n",ok);
     }
     
     case SIMPLE_ERROR:
     { 
        gaim_debug(GAIM_DEBUG_INFO,"sippy","got an ERROR messages from gag\n");
        sippy_get_string( buf, sizeof(buf) );
        gaim_debug(GAIM_DEBUG_INFO,"sippy","gag ERROR %s\n",buf);
        gaim_request_action(gc, _("SIP Error"), _("SIP Error"), buf, 
                             0, NULL, 1, _("Okay"), 0);
     }
     break;
     
     default:
        resip_assert(0);
  }
}
コード例 #20
0
ファイル: weblogin.c プロジェクト: BackupTheBerlios/qrc-svn
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);
	
	}
	
	
}
コード例 #21
0
static gboolean
_parse_data(TrepiaSession *session, char *buf)
{
	GHashTable *info;
	GaimAccount *account;
	TrepiaMessageType type = 0;
	TrepiaProfile *profile = NULL;
	int ret;
	char *buffer;
	GaimBuddy *b;
	int id = 0;
	const char *value;
	char *username;
	int *int_p;
	GMainContext *ctx;

	account = gaim_connection_get_account(session->gc);

	ret = __parse_message(buf, &type, &info);

	if (ret == 1)
		return TRUE;

	if (info != NULL) {
		switch (type) {
			case TREPIA_USER_LIST:
				gaim_connection_update_progress(session->gc,
						_("Retrieving buddy list"), 2, TREPIA_CONNECT_STEPS);

				gaim_connection_set_state(session->gc, GAIM_CONNECTED);
				serv_finish_login(session->gc);
				break;

			case TREPIA_MSG_INCOMING: /* Incoming Message */
				id = atoi(g_hash_table_lookup(info, "a"));

				profile = g_hash_table_lookup(session->user_profiles, &id);
				serv_got_im(session->gc,
							trepia_profile_get_login(profile),
							(char *)g_hash_table_lookup(info, "b"),
							0, time(NULL));
				break;

			case TREPIA_MEMBER_UPDATE:
				profile = trepia_profile_new();

				if ((value = g_hash_table_lookup(info, "a")) != NULL) {
					id = atoi(value);
					trepia_profile_set_id(profile, id);
				}

				if ((value = g_hash_table_lookup(info, "b")) != NULL)
					trepia_profile_set_login_time(profile, atoi(value));

				if ((value = g_hash_table_lookup(info, "c")) != NULL)
					trepia_profile_set_type(profile, atoi(value));
				else
					trepia_profile_set_type(profile, 2);

				session->pending_users = g_list_append(session->pending_users,
													   profile);


#if 0
				if (trepia_profile_get_type(profile) == 1) {
					buffer = g_strdup_printf(
						"<D>"
						"<a>%d</a>"
						"<b>1</b>"
						"</D>",
						id);
				}
				else {
#endif
					buffer = g_strdup_printf(
						"<D>"
						"<a>%d</a>"
						"<b>1</b>"
						"</D>"
						"<D>"
						"<a>%d</a>"
						"<b>2</b>"
						"</D>",
						id,
						id);
#if 0
				}
#endif

				if (trepia_write(session->fd, buffer, strlen(buffer)) < 0) {
					gaim_connection_error(session->gc, _("Write error"));
					g_free(buffer);
					return 1;
				}

				g_free(buffer);
				break;

			case TREPIA_MEMBER_PROFILE:
				if ((value = g_hash_table_lookup(info, "a")) != NULL) {
					GList *l;

					id = atoi(value);

					for (l = session->pending_users; l != NULL; l = l->next) {
						profile = l->data;

						if (trepia_profile_get_id(profile) == id)
							break;

						profile = NULL;
					}
				}
				else
					break;

				if (profile == NULL) {
					profile = g_hash_table_lookup(session->user_profiles, &id);

					if (profile == NULL)
						break;
				}

				/* Age */
				if ((value = g_hash_table_lookup(info, "m")) != NULL)
					trepia_profile_set_age(profile, atoi(value));

				/* ICQ */
				if ((value = g_hash_table_lookup(info, "i")) != NULL)
					trepia_profile_set_icq(profile, atoi(value));

				/* Sex */
				if ((value = g_hash_table_lookup(info, "n")) != NULL)
					trepia_profile_set_sex(profile, *value);

				/* Location */
				if ((value = g_hash_table_lookup(info, "p")) != NULL)
					trepia_profile_set_location(profile, value);

				/* First Name */
				if ((value = g_hash_table_lookup(info, "g")) != NULL)
					trepia_profile_set_first_name(profile, value);

				/* Last Name */
				if ((value = g_hash_table_lookup(info, "h")) != NULL)
					trepia_profile_set_last_name(profile, value);

				/* Profile */
				if ((value = g_hash_table_lookup(info, "o")) != NULL)
					trepia_profile_set_profile(profile, value);

				/* E-mail */
				if ((value = g_hash_table_lookup(info, "e")) != NULL)
					trepia_profile_set_email(profile, value);

				/* AIM */
				if ((value = g_hash_table_lookup(info, "j")) != NULL)
					trepia_profile_set_aim(profile, value);

				/* MSN */
				if ((value = g_hash_table_lookup(info, "k")) != NULL)
					trepia_profile_set_msn(profile, value);

				/* Yahoo */
				if ((value = g_hash_table_lookup(info, "l")) != NULL)
					trepia_profile_set_yahoo(profile, value);

				/* Homepage */
				if ((value = g_hash_table_lookup(info, "f")) != NULL)
					trepia_profile_set_homepage(profile, value);

				/* Country */
				if ((value = g_hash_table_lookup(info, "r")) != NULL)
					trepia_profile_set_country(profile, value);

				/* State */
				if ((value = g_hash_table_lookup(info, "s")) != NULL)
					trepia_profile_set_state(profile, value);

				/* City */
				if ((value = g_hash_table_lookup(info, "t")) != NULL)
					trepia_profile_set_city(profile, value);

				/* Languages */
				if ((value = g_hash_table_lookup(info, "u")) != NULL)
					trepia_profile_set_languages(profile, value);

				/* School */
				if ((value = g_hash_table_lookup(info, "v")) != NULL)
					trepia_profile_set_school(profile, value);

				/* Company */
				if ((value = g_hash_table_lookup(info, "w")) != NULL)
					trepia_profile_set_company(profile, value);

				/* Login Name */
				if ((value = g_hash_table_lookup(info, "d")) != NULL) {
					trepia_profile_set_login(profile, value);
					username = g_strdup(value);
				}
				else if ((value = trepia_profile_get_login(profile)) != NULL) {
					username = g_strdup(value);
				}
				else {
					username = g_strdup_printf("%d", id);
					trepia_profile_set_login(profile, username);
				}

				b = gaim_find_buddy(account, username);

				if (b == NULL) {
					GaimGroup *g;

					g = gaim_find_group(_("Local Users"));

					if (g == NULL) {
						g = gaim_group_new(_("Local Users"));
						gaim_blist_add_group(g, NULL);
					}

					b = gaim_buddy_new(account, username, NULL);

					gaim_blist_add_buddy(b, NULL, g, NULL);
				}

				profile->buddy = b;

				b->proto_data = profile;

				session->pending_users = g_list_remove(session->pending_users,
													   profile);

				int_p = g_new0(int, 1);
				*int_p = id;
				g_hash_table_insert(session->user_profiles, int_p, profile);

				serv_got_update(session->gc,
								username, TRUE, 0,
								trepia_profile_get_login_time(profile), 0, 0);

				/* Buddy Icon */
				if ((value = g_hash_table_lookup(info, "q")) != NULL) {
					char *icon;
					int icon_len;

					gaim_base64_decode(value, &icon, &icon_len);

					gaim_buddy_icons_set_for_user(session->gc->account,
							username, icon, icon_len);

					g_free(icon);

					serv_got_update(session->gc, username, TRUE, 0, 0, 0, 0);
				}

				/*
				 * XXX
				 * This does nothing when using a non-gtk event loop.
				 * What is it supposed to accomplish anyway?
				 */
				ctx = g_main_context_default();

				while (g_main_context_pending(ctx))
					g_main_context_iteration(ctx, FALSE);

				g_free(username);

				break;

			case TREPIA_MEMBER_OFFLINE:
				if ((value = g_hash_table_lookup(info, "a")) != NULL)
					id = atoi(value);
				else
					break;

				profile = g_hash_table_lookup(session->user_profiles, &id);

				if (profile == NULL)
					break;

				g_hash_table_remove(session->user_profiles, &id);

				b = profile->buddy;

				if (b != NULL)
					serv_got_update(session->gc,
									trepia_profile_get_login(profile),
									FALSE, 0, 0, 0, 0);

				gaim_blist_remove_buddy(b);

				break;

			default:
				break;
		}

		g_hash_table_destroy(info);
	}
	else {
コード例 #22
0
ファイル: weblogin.c プロジェクト: BackupTheBerlios/qrc-svn
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);

}
コード例 #23
0
ファイル: gaym.c プロジェクト: BackupTheBerlios/qrc-svn
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;
}
コード例 #24
0
ファイル: gaym.c プロジェクト: BackupTheBerlios/qrc-svn
static void gaym_login(GaimAccount * account)
{
    GaimConnection *gc;
    struct gaym_conn *gaym;
    char *buf;
    const char *username = gaim_account_get_username(account);

    gc = gaim_account_get_connection(account);
    gc->flags |= GAIM_CONNECTION_NO_NEWLINES | GAIM_CONNECTION_AUTO_RESP;

    if (strpbrk(username, " \t\v\r\n") != NULL) {
        gaim_connection_error(gc,
                              _("IRC nicks may not contain whitespace"));
        return;
    }

    gc->proto_data = gaym = g_new0(struct gaym_conn, 1);
    gaym->account = account;


    /**
     * gaim_connection_set_display_name(gc, userparts[0]);
     */
    gaim_connection_set_display_name(gc, username);
    gaym->server =
        g_strdup(gaim_account_get_string
                 (account, "server", "www.gay.com"));
    /**
     * gaym->server = "www.gay.com";
     */
    gaym->buddies =
        g_hash_table_new_full((GHashFunc) gaym_nick_hash,
                              (GEqualFunc) gaym_nick_equal, NULL,
                              (GDestroyNotify) gaym_buddy_free);

    gaym->channel_members =
        g_hash_table_new_full((GHashFunc) gaym_nick_hash,
                              (GEqualFunc) gaym_nick_equal, NULL,
                              (GDestroyNotify) gaym_channel_member_free);

    gaym->cmds = g_hash_table_new(g_str_hash, g_str_equal);
    gaym_cmd_table_build(gaym);
    gaym->msgs = g_hash_table_new(g_str_hash, g_str_equal);
    gaym_msg_table_build(gaym);
    gaym->roomlist_filter = NULL;

    gaym->hammers = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)hammer_cb_data_destroy);
    /**
     * The last parameter needs to be NULL here, since the same
     * field is added for both the key and the value (and if we
     * free it twice, thats bad and causes crashing!).
     */
    gaym->info_window_needed =
        g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);

    gaym->entry_order =
        g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);

    /**
     * This is similar to gaym->info_window_needed, except this is
     * for thumbails inside the IM conversation window if the
     * person is not already on the buddy list
     */

    buf = g_strdup_printf(_("Signon: %s"), username);
    gaim_connection_update_progress(gc, buf, 1, 6);
    g_free(buf);


    /**
     * Making a change to try cached password first.
     * gaym_try_cached_password(account, gaym_login_with_chat_key);
     */
    gaym_get_chat_key_from_weblogin(account, gaym_login_with_chat_key);
}