Example #1
0
void
gaim_connection_connect(GaimConnection *gc)
{
	GaimAccount *account;
	GaimConnectionUiOps *ops;
	GaimPluginProtocolInfo *prpl_info = NULL;

	g_return_if_fail(gc != NULL);

	gaim_debug(GAIM_DEBUG_INFO, "connection",
			   "Connecting. gc = %p\n", gc);

	ops = gaim_get_connection_ui_ops();

	if (gc->prpl != NULL)
	        prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
	else {
	        gchar *message = g_strdup_printf(_("Missing protocol plugin for %s"),
						 gaim_account_get_username(gaim_connection_get_account(gc)));

		gaim_debug(GAIM_DEBUG_ERROR, "connection",
			   "Could not get prpl info for %p\n", gc);
		gaim_notify_error(NULL, _("Connection Error"),
				  message, NULL);
		g_free(message);
		return;
	}

	account = gaim_connection_get_account(gc);

	if (gaim_connection_get_state(gc) != GAIM_DISCONNECTED)
		return;

	if (!(prpl_info->options & OPT_PROTO_NO_PASSWORD) &&
			!(prpl_info->options & OPT_PROTO_PASSWORD_OPTIONAL) &&
			gaim_account_get_password(account) == NULL) {
		gchar *primary;
		gchar *escaped;
		const gchar *username = gaim_account_get_username(account);

		gaim_debug(GAIM_DEBUG_INFO, "connection", "Requesting password\n");
		gaim_connection_destroy(gc);
		escaped = g_markup_escape_text(username, strlen(username));
		primary = g_strdup_printf(_("Enter password for %s"), escaped);
		gaim_request_input(gc, NULL, primary, NULL, NULL, FALSE, TRUE,
						   _("OK"), G_CALLBACK(request_pass_ok_cb),
						   _("Cancel"), NULL, account);
		g_free(primary);
		g_free(escaped);

		return;
	}

	gaim_connection_set_state(gc, GAIM_CONNECTING);

	connections = g_list_append(connections, gc);

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

	gaim_debug(GAIM_DEBUG_INFO, "connection", "Calling serv_login\n");

	serv_login(account);
}
Example #2
0
void MainWindow::read()
{
    ui->textBrowser->append("");

    QByteArray data;
    data = client->readAll();
    QString s = QString(data);

    ui->textBrowser->append("Data input: "+QString(data));
    QStringList l = s.split("||");
    if (l[0] == "LOGIN")
    {
        serv_login(l[1],l[2]);
    }
    else if (l[0] == "REGISTER")
    {
        serv_register(l[1],l[2]);
    }
    else if (l[0] == "CHECK_TOKEN")
    {
        serv_checkToken(l[1]);
    }
    else if (l[0] == "GET_DATA")
    {
        serv_sendData(l[1]);
    }
    else if (l[0] == "NEW_CAT")
    {
        serv_newCat(l[1],l[2],l[3]);
    }
    else if (l[0] == "DEL_CAT")
    {
        serv_delCat(l[1],l[2]);
    }
    else if (l[0] == "LOG_OUT")
    {
        serv_logOut(l[1]);
    }
    else if (l[0] == "NEW_TAG")
    {
        serv_newTag(l[1],l[2]);
    }
    else if (l[0] == "DEL_TAG")
    {
        serv_delTag(l[1],l[2]);
    }
    else if (l[0] == "SHARE_NOTE")
    {
        serv_shareNote(l[1],l[2],l[3]);
    }
    else if (l[0] == "NEW_NOTE")
    {
        serv_createNote(l[1], l[2]);
    }
    else if (l[0] == "UPDATE_NOTE")
    {
        serv_updateNote(l[1], l[2]);
    }
    else if (l[0] == "DEL_NOTE")
    {
        serv_delNote(l[1],l[2]);
    }
    else
    {
        ui->textBrowser->append("Error appeared while reading request.");

        client->write("UNERR");
        ui->textBrowser->append("UNERR");
    }
}