예제 #1
0
파일: loginpanel.c 프로젝트: jayivy/gtkqq
//
// Update the details.
//
static void update_details(QQInfo *info, QQLoginPanel *panel)
{
    // update my information
    qq_get_buddy_info(info, info -> me, NULL);
    gqq_mainloop_attach(&gtkloop
                        , qq_mainpanel_update_my_info
                        , 1
                        , QQ_MAINWINDOW(panel -> container) -> main_panel);

    // update online buddies
    qq_get_online_buddies(info, NULL);
    gqq_mainloop_attach(&gtkloop
                        , qq_mainpanel_update_online_buddies
                        , 1
                        , QQ_MAINWINDOW(panel -> container) -> main_panel);

    //update qq number
    update_buddy_qq_number(info
                           , (QQMainPanel*)QQ_MAINWINDOW(panel -> container) 
                           -> main_panel);
    // update group number
    gint i;
    QQGroup *grp;
    gchar num[100];
    for(i = 0; i < info -> groups -> len; ++i){
        grp = g_ptr_array_index(info -> groups, i);
        if(grp == NULL){
            continue;
        }
        qq_get_qq_number(info, grp -> code -> str, num, NULL);
        qq_group_set(grp, "gnumber", num);
    }
    gqq_mainloop_attach(&gtkloop
                        , qq_mainpanel_update_group_info 
                        , 1
                        , QQ_MAINWINDOW(panel -> container) -> main_panel);

    //update face image
    update_face_image(info
                      , (QQMainPanel*)QQ_MAINWINDOW(panel -> container) 
                      -> main_panel);
}
예제 #2
0
파일: dao.c 프로젝트: wanderxjtu/gtkqq
gint db_get_group(sqlite3 *db, const gchar *owner, QQGroup *grp, gint *cnt)
{
    if(db == NULL || owner == NULL || grp == NULL){
        return SQLITE_ERROR;
    }

    gchar sql[500];
    g_snprintf(sql, 500, "select name, flag, creator, mark, mask, "
                    "opt, createtime, gclass, glevel, face, memo, fingermemo"
                    " from groups where owner='%s' and gnumber = '%s';"
                                    , owner, grp -> gnumber -> str);

    g_debug("Run sql : %s (%s, %d)", sql, __FILE__, __LINE__);
    sqlite3_stmt *stmt = NULL;
    if(sqlite3_prepare_v2(db, sql, 500, &stmt, NULL) != SQLITE_OK){
        g_warning("prepare sql error. SQL(%s) (%s, %d)", sql
                        , __FILE__, __LINE__);
        return SQLITE_ERROR;
    }

    gint retcode = SQLITE_OK;
    gint num = 0;
    while(TRUE){
        retcode = sqlite3_step(stmt);
        switch(retcode)
        {
        case SQLITE_ROW:
            qq_group_set(grp, "name", (const gchar *)sqlite3_column_text(stmt, 0));
            qq_group_set(grp, "flag", (const gchar *)sqlite3_column_text(stmt, 1));
            qq_group_set(grp, "owner", (const gchar *)sqlite3_column_text(stmt, 2));
            qq_group_set(grp, "mark", (const gchar *)sqlite3_column_text(stmt, 3));
            qq_group_set(grp, "mask", (const gchar *)sqlite3_column_text(stmt, 4));
            qq_group_set(grp, "option", (const gchar *)sqlite3_column_text(stmt, 5));
            qq_group_set(grp, "createtime", (const gchar *)sqlite3_column_text(stmt, 6));
            qq_group_set(grp, "gclass", (const gchar *)sqlite3_column_text(stmt, 7));
            qq_group_set(grp, "level", (const gchar *)sqlite3_column_text(stmt, 8));
            qq_group_set(grp, "face", (const gchar *)sqlite3_column_text(stmt, 9));
            qq_group_set(grp, "memo", (const gchar *)sqlite3_column_text(stmt, 10));
            qq_group_set(grp, "fingermemo", (const gchar *)sqlite3_column_text(stmt, 11));
            //get group members
            db_get_group_members(db, grp);
            ++num;
            break;
        case SQLITE_DONE:
            retcode = SQLITE_OK;
            goto out_label;
            break;
        default:
            g_warning("sqlite3_step error!(%s, %d)", __FILE__, __LINE__);
            goto out_label;
            break;
        }
    }

out_label:
    if(cnt != NULL){
        *cnt = num;
    }
    sqlite3_finalize(stmt);
    return retcode;
}