Browse files

修复一个 64 位强制类型检查下编译的错误

完善记住密码和忘记密码功能
  • Loading branch information...
1 parent f39d620 commit f0801c272fc98bd8eb51f730242dc8bb47fdcb9b @mathslinux mathslinux committed Nov 29, 2011
Showing with 53 additions and 14 deletions.
  1. +1 −0 AUTHORS
  2. +6 −5 src/gui/dao.c
  3. +1 −1 src/gui/dao.h
  4. +24 −6 src/gui/gqqconfig.c
  5. +1 −0 src/gui/gqqconfig.h
  6. +16 −1 src/gui/loginpanel.c
  7. +2 −0 src/gui/loginpanel.h
  8. +2 −1 src/libqq/url.c
View
1 AUTHORS
@@ -1,2 +1,3 @@
HuangCongyu <huangcongyu2006@gmail.com>
Xiang Wang <wxjeacen@gmail.com>
+mathslinux <riegamaths@gmail.com>
View
11 src/gui/dao.c
@@ -16,7 +16,7 @@ static const gchar table_sql[] =
" owner, key, value);"
"create table if not exists qquser("
" qqnumber primary key ,"
- " passwd, status, last);"
+ " passwd, status, last, rempw);"
"create table if not exists buddies("
" qqnumber primary key,"
" owner,vip_info, nick, markname, "
@@ -110,7 +110,7 @@ gint db_get_all_users(sqlite3 *db, GPtrArray **result)
if(db == NULL || result == NULL){
return SQLITE_ERROR;
}
- static const gchar *sql = "select qqnumber,last,passwd,status from qquser;";
+ static const gchar *sql = "select qqnumber,last,passwd,status,rempw from qquser;";
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
@@ -132,6 +132,7 @@ gint db_get_all_users(sqlite3 *db, GPtrArray **result)
g_strlcpy(usr -> qqnumber
, (const gchar *)sqlite3_column_text(stmt, 0), 100);
usr -> last = sqlite3_column_int(stmt, 1);
+ usr -> rempw = sqlite3_column_int(stmt, 4);
decode_passwed = (gchar *)g_base64_decode(
(const gchar *)sqlite3_column_text(stmt, 2)
, &out_len);
@@ -204,7 +205,7 @@ gint db_clear_table(sqlite3 *db, const gchar *table
}
gint db_qquser_save(sqlite3 *db, const gchar *qqnum, const gchar *passwd
- , const gchar *status, gint last)
+ , const gchar *status, gint last, gint rempw)
{
if(db == NULL || qqnum == NULL){
return SQLITE_ERROR;
@@ -213,8 +214,8 @@ gint db_qquser_save(sqlite3 *db, const gchar *qqnum, const gchar *passwd
, (gsize)strlen(passwd));
gchar sql[500];
g_snprintf(sql, 500, "insert or replace into qquser (qqnumber, last, "
- "passwd, status)values('%s', %d, '%s', '%s');"
- , qqnum, last, encoded_passwd, status);
+ "passwd, status, rempw)values('%s', %d, '%s', '%s', '%d');"
+ , qqnum, last, encoded_passwd, status, rempw);
gchar *err = NULL;
sqlite3_exec(db, sql, NULL, NULL, &err);
if(err != NULL){
View
2 src/gui/dao.h
@@ -47,7 +47,7 @@ gint db_clear_table(sqlite3 *db, const gchar *table
// Store qq user into db
//
gint db_qquser_save(sqlite3 *db, const gchar *qqnum, const gchar *passwd
- , const gchar *status, gint last);
+ , const gchar *status, gint last, gint rempw);
//
// Store key:value into db
View
30 src/gui/gqqconfig.c
@@ -29,6 +29,7 @@ typedef struct{
GString *passwd; //stored password
GString *qqnum; //current user's qq number
GString *status; //current user's status
+ gint rempw; //whether remember password
sqlite3 *db_con; //database connection
@@ -47,6 +48,7 @@ enum{
GQQ_CONFIG_PROPERTY_PASSWD,
GQQ_CONFIG_PROPERTY_UIN,
GQQ_CONFIG_PROPERTY_STATUS,
+ GQQ_CONFIG_PROPERTY_REMPW,
};
static void gqq_config_init(GQQConfig *self);
@@ -113,7 +115,7 @@ static void gqq_config_getter(GObject *object, guint property_id,
object, gqq_config_get_type(), GQQConfig);
GQQConfigPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE(
obj, gqq_config_get_type(), GQQConfigPriv);
-
+
switch (property_id)
{
case GQQ_CONFIG_PROPERTY_INFO:
@@ -128,6 +130,9 @@ static void gqq_config_getter(GObject *object, guint property_id,
case GQQ_CONFIG_PROPERTY_UIN:
g_value_set_static_string(value, priv -> qqnum -> str);
break;
+ case GQQ_CONFIG_PROPERTY_REMPW:
+ priv -> rempw = g_value_get_int(value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
break;
@@ -143,11 +148,10 @@ static void gqq_config_setter(GObject *object, guint property_id,
if(object == NULL || value == NULL || property_id < 0){
return;
}
- g_debug("GQQConfig setter: %s (%s, %d)", pspec -> name, __FILE__, __LINE__);
+ g_debug("GQQConfig setter: %s (%s, %d)", pspec -> name, __FILE__, __LINE__);
GQQConfig *obj = GQQ_CONFIG(object);
GQQConfigPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE(
obj, gqq_config_get_type(), GQQConfigPriv);
-
switch (property_id)
{
case GQQ_CONFIG_PROPERTY_INFO:
@@ -165,11 +169,14 @@ static void gqq_config_setter(GObject *object, guint property_id,
g_string_truncate(priv -> qqnum , 0);
g_string_append(priv -> qqnum , g_value_get_string(value));
break;
+ case GQQ_CONFIG_PROPERTY_REMPW:
+ priv -> rempw = g_value_get_int(value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
break;
}
-}
+}
#ifdef G_ENABLE_DEBUG
#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v)
@@ -257,6 +264,7 @@ static void gqq_config_init(GQQConfig *self)
priv -> passwd = g_string_new(NULL);
priv -> qqnum = g_string_new(NULL);
priv -> status = g_string_new(NULL);
+ priv -> rempw = 0;
priv -> db_con = db_open();
priv -> ht_ht = g_hash_table_new_full(g_str_hash, g_str_equal
, g_free, NULL);
@@ -326,6 +334,17 @@ static void gqq_config_class_init(GQQConfigClass *klass, gpointer data)
g_object_class_install_property(G_OBJECT_CLASS(klass)
, GQQ_CONFIG_PROPERTY_STATUS, pspec);
+ //install the rempw property
+ pspec = g_param_spec_int("rempw"
+ , "rempw"
+ , "Whather remember the password."
+ , 0
+ , 1
+ , 0
+ , G_PARAM_READABLE | G_PARAM_WRITABLE);
+ g_object_class_install_property(G_OBJECT_CLASS(klass)
+ , GQQ_CONFIG_PROPERTY_REMPW, pspec);
+
}
//
@@ -398,11 +417,10 @@ gint gqq_config_save_last_login_user(GQQConfig *cfg)
{
GQQConfigPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE(
cfg, gqq_config_get_type(), GQQConfigPriv);
- //Save the last login user.
if(priv -> qqnum -> len > 0){
db_update_all(priv -> db_con, "qquser", "last", "0");
db_qquser_save(priv -> db_con, priv -> qqnum -> str, priv -> passwd -> str
- , priv -> status -> str, 1);
+ , priv -> status -> str, 1, priv->rempw);
}
return 0;
}
View
1 src/gui/gqqconfig.h
@@ -15,6 +15,7 @@ typedef struct __GQQLoginUser{
gchar passwd[100];
gchar status[100];
gint last;
+ gint rempw;
}GQQLoginUser;
#define GQQ_TYPE_CONFIG (gqq_config_get_type())
View
17 src/gui/loginpanel.c
@@ -305,10 +305,12 @@ static void login_btn_cb(GtkButton *btn, gpointer data)
QQLoginPanel *panel = QQ_LOGINPANEL(data);
GtkWidget *win = panel -> container;
qq_mainwindow_show_splashpanel(win);
+
panel -> uin = qq_loginpanel_get_uin(panel);
panel -> passwd = qq_loginpanel_get_passwd(panel);
panel -> status = qq_loginpanel_get_status(panel);
+ panel -> rempw = qq_loginpanel_get_rempw(panel);
g_debug("Start login... qqnum: %s, status: %s (%s, %d)", panel -> uin
, panel -> status, __FILE__, __LINE__);
@@ -321,6 +323,7 @@ static void login_btn_cb(GtkButton *btn, gpointer data)
g_object_set(cfg, "qqnum", panel -> uin, NULL);
g_object_set(cfg, "passwd", panel -> passwd, NULL);
g_object_set(cfg, "status", panel -> status, NULL);
+ g_object_set(cfg, "rempw", panel -> rempw, NULL);
qq_buddy_set(info -> me, "qqnumber", panel -> uin);
qq_buddy_set(info -> me, "uin", panel -> uin);
@@ -366,7 +369,8 @@ static void qq_loginpanel_init(QQLoginPanel *obj)
obj -> passwd_entry = gtk_entry_new();
if(login_users -> len > 0){
usr = (GQQLoginUser*)g_ptr_array_index(login_users, 0);
- gtk_entry_set_text(GTK_ENTRY(obj -> passwd_entry), usr -> passwd);
+ if (usr->rempw)
+ gtk_entry_set_text(GTK_ENTRY(obj -> passwd_entry), usr -> passwd);
}
g_signal_connect(G_OBJECT(obj -> uin_entry), "changed"
, G_CALLBACK(qqnumber_combox_changed), obj);
@@ -398,6 +402,12 @@ static void qq_loginpanel_init(QQLoginPanel *obj)
//rember password check box
obj -> rempwcb = gtk_check_button_new_with_label("Remeber Password");
+ if(login_users -> len > 0){
+ usr = (GQQLoginUser*)g_ptr_array_index(login_users, 0);
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(obj -> rempwcb), usr->rempw);
+ }
+ /* g_signal_connect(G_OBJECT(obj -> rempwcb), "toggled" */
+ /* , G_CALLBACK(qqnumber_combox_changed), obj); */
GtkWidget *hbox4 = gtk_hbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox4), obj -> rempwcb, TRUE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), hbox4, FALSE, TRUE, 2);
@@ -488,6 +498,11 @@ const gchar* qq_loginpanel_get_status(QQLoginPanel *loginpanel)
return qq_statusbutton_get_status_string(loginpanel -> status_comb);
}
+gint qq_loginpanel_get_rempw(QQLoginPanel *loginpanel)
+{
+ return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(loginpanel->rempwcb));
+}
+
typedef struct{
QQInfo *info;
GPtrArray *array;
View
2 src/gui/loginpanel.h
@@ -40,6 +40,7 @@ struct _QQLoginPanel{
GtkWidget *login_btn, *status_comb;
const gchar *uin, *passwd, *status;
+ gint rempw;
GtkWidget *container;
@@ -66,4 +67,5 @@ GtkType qq_loginpanel_get_type();
const gchar* qq_loginpanel_get_uin(QQLoginPanel *loginpanel);
const gchar* qq_loginpanel_get_passwd(QQLoginPanel *loginpanel);
const gchar* qq_loginpanel_get_status(QQLoginPanel *loginpanel);
+gint qq_loginpanel_get_rempw(QQLoginPanel *loginpanel);
#endif
View
3 src/libqq/url.c
@@ -386,8 +386,9 @@ gint rcv_response(Connection *con, Response **rp)
break;
}
}else{
+ /* Format data->len so that it can be compiled on x86-64 machine */
g_debug("More chunks... Begin %d len %d %s(%s, %d)"
- , chunkbegin, data -> len
+ , chunkbegin, (int)data -> len
, data -> str + chunkbegin
, __FILE__, __LINE__);
break;

0 comments on commit f0801c2

Please sign in to comment.