soc.2009.transport: b133e125: Allow user to choose language in registr...
hanzz at soc.pidgin.im
hanzz at soc.pidgin.im
Fri Jun 5 18:00:38 EDT 2009
-----------------------------------------------------------------
Revision: b133e1254b397d4fff78ee1633b0da9a772f3dc4
Ancestor: 4cfb3e95b4d7da08c5d2ba1af356d09d31f1d1c9
Author: hanzz at soc.pidgin.im
Date: 2009-06-05T21:55:26
Branch: im.pidgin.soc.2009.transport
URL: http://d.pidgin.im/viewmtn/revision/info/b133e1254b397d4fff78ee1633b0da9a772f3dc4
Modified files:
registerhandler.cpp schemas/mysql_schema.sql sql.cpp sql.h
ChangeLog:
Allow user to choose language in registration form
-------------- next part --------------
============================================================
--- registerhandler.cpp 655a3c34fa3cf5c9e71a6c8548eba859f3b8e2b0
+++ registerhandler.cpp 76468ce31cdb36168462cc3cc9810ad4d342a274
@@ -61,6 +61,7 @@ bool GlooxRegisterHandler::handleIq (con
query->addChild( new Tag("instructions", p->protocol()->text("instructions")) );
query->addChild( new Tag("username") );
query->addChild( new Tag("password") );
+ query->addChild( new Tag("language", "cs") );
}
else {
std::cout << "* sending registration form; user is registered\n";
@@ -68,6 +69,7 @@ bool GlooxRegisterHandler::handleIq (con
query->addChild( new Tag("registered") );
query->addChild( new Tag("username",res.uin));
query->addChild( new Tag("password"));
+ query->addChild( new Tag("language", res.language) );
}
reply->addChild(query);
@@ -161,8 +163,14 @@ bool GlooxRegisterHandler::handleIq (con
std::string jid = iq.from().bare();
Tag *usernametag = query->findChild("username");
Tag *passwordtag = query->findChild("password");
+ Tag *languagetag = query->findChild("password");
std::string username("");
std::string password("");
+ std::string language("");
+
+ if (languagetag)
+ language = languagetag->cdata();
+
bool e = false;
if (usernametag==NULL || passwordtag==NULL)
e=true;
@@ -224,12 +232,12 @@ bool GlooxRegisterHandler::handleIq (con
// } else {
std::cout << "* adding new user: "<< jid << ", " << username << ", " << password <<"\n";
- p->sql()->addUser(jid,username,password);
+ p->sql()->addUser(jid,username,password,language);
sendsubscribe = true;
} else {
// change password
std::cout << "* changing user password: "<< jid << ", " << username << ", " << password <<"\n";
- p->sql()->updateUserPassword(iq.from().bare(),password);
+ p->sql()->updateUserPassword(iq.from().bare(),password,language);
}
Tag *reply = new Tag( "iq" );
reply->addAttribute( "id", iq.id() );
============================================================
--- schemas/mysql_schema.sql 473aafa6dbb46e82aedeb154b02c9e327bea1626
+++ schemas/mysql_schema.sql 98c03912ec58aa665c3c837036f19ff403e92553
@@ -3,6 +3,7 @@ CREATE TABLE `users` (
`jid` varchar(255) collate utf8_bin NOT NULL,
`uin` varchar(255) collate utf8_bin NOT NULL,
`password` varchar(255) collate utf8_bin NOT NULL,
+ `language` varchar(5) collate utf8_bin NOT NULL,
`group` int(11) NOT NULL default '0',
PRIMARY KEY (`id`),
KEY `jid` (`jid`),
============================================================
--- sql.cpp 4c53aa5cc93ea9b8c04b618d2a46cfe082ae936b
+++ sql.cpp ff3df8968af4fc830d92acf4d407b2ff8d00671b
@@ -114,9 +114,9 @@ long SQLClass::getRegisteredUsersRosterC
}
-void SQLClass::updateUserPassword(const std::string &jid,const std::string &password) {
+void SQLClass::updateUserPassword(const std::string &jid,const std::string &password,const std::string &language) {
mysqlpp::Query query = sql->query();
- query << "UPDATE "<< p->configuration().sqlPrefix <<"users SET password=\"" << password <<"\" WHERE jid=\"" << jid << "\";";
+ query << "UPDATE "<< p->configuration().sqlPrefix <<"users SET password=\"" << password <<"\", language=\""<< language <<"\" WHERE jid=\"" << jid << "\";";
query.execute();
}
@@ -144,9 +144,9 @@ void SQLClass::addDownload(const std::st
query.execute();
}
-void SQLClass::addUser(const std::string &jid,const std::string &uin,const std::string &password){
+void SQLClass::addUser(const std::string &jid,const std::string &uin,const std::string &password,const std::string &language){
mysqlpp::Query query = sql->query();
- query << "INSERT INTO "<< p->configuration().sqlPrefix <<"users " << "(id, jid, uin, password) VALUES (\"\",\"" << jid << "\",\"" << uin << "\", \"" << password << "\")";
+ query << "INSERT INTO "<< p->configuration().sqlPrefix <<"users " << "(id, jid, uin, password, language) VALUES (\"\",\"" << jid << "\",\"" << uin << "\", \"" << password << "\", \"" << language << "\")";
query.execute();
}
============================================================
--- sql.h dc96d4e220d067ecea126925c7c15605d37a169d
+++ sql.h f285872eec2f7639f2d4ab8b0b52a9705d43bd69
@@ -33,6 +33,7 @@ struct UserRow {
std::string jid;
std::string uin;
std::string password;
+ std::string language;
int category;
};
@@ -54,10 +55,10 @@ public:
public:
SQLClass(GlooxMessageHandler *parent);
// ~SQLClass();
- void addUser(const std::string &jid,const std::string &uin,const std::string &password);
+ void addUser(const std::string &jid,const std::string &uin,const std::string &password, const std::string &language);
void addDownload(const std::string &filename,const std::string &vip);
void removeUser(const std::string &jid);
- void updateUserPassword(const std::string &jid,const std::string &password);
+ void updateUserPassword(const std::string &jid,const std::string &password, const std::string &language);
void removeUserFromRoster(const std::string &jid);
void addUserToRoster(const std::string &jid,const std::string &uin,const std::string subscription);
void updateUserRosterSubscription(const std::string &jid,const std::string &uin,const std::string subscription);
More information about the Commits
mailing list