|
|
@@ -4859,6 +4859,9 @@ int dev_switch_update_all(sqlite3 *db, netswitch_info_t *sw)
|
|
|
////////////////MAIL/////////////////////////////////////////////
|
|
|
#define MAIL_MANAGER_TABLE "Table_MAILManage"
|
|
|
#define MAIL_RECVEIVE_TABLE "Table_MAILReceive"
|
|
|
+#define TENCENT_CLOUD_SMS_INFO_TABLE "Table_TencentCloudSmsInfo"
|
|
|
+#define TENCENT_CLOUD_SMS_PHONE "Table_TencentCloudSmsPhone"
|
|
|
+
|
|
|
int dev_mail_get(sqlite3 *db, mail_info_t *info)
|
|
|
{
|
|
|
int i,r=-1;
|
|
|
@@ -4934,6 +4937,143 @@ int dev_mail_get(sqlite3 *db, mail_info_t *info)
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+int dev_tencent_cloud_get(sqlite3 *db, cloud_info_t *info)
|
|
|
+{
|
|
|
+ int i,r=-1;
|
|
|
+ char temp[1024];
|
|
|
+ char *err_msg=NULL;
|
|
|
+ char *table=NULL;
|
|
|
+ int nrow,ncol;
|
|
|
+ char** pResult = NULL;
|
|
|
+
|
|
|
+ if(!info) {
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ memset(info, 0, sizeof(cloud_info_t));
|
|
|
+ nrow = ncol = 0;
|
|
|
+
|
|
|
+ table = TENCENT_CLOUD_SMS_INFO_TABLE;
|
|
|
+ sprintf(temp, "SELECT * FROM %s;", table);
|
|
|
+ r = sqlite3_get_table(db, temp, &pResult, &nrow, &ncol, &err_msg);
|
|
|
+ if(r != SQLITE_OK) {
|
|
|
+ log_e("sqlite handle error: %s \n%s\n", temp, err_msg); sqlite3_free(err_msg);
|
|
|
+ return -1 ;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(info && ncol>0) {
|
|
|
+ tencent_cloud_info_t *info_info=&info->info;
|
|
|
+ memset(info_info, 0, sizeof(tencent_cloud_info_t));
|
|
|
+ info_info->id = atoi(pResult[ncol+0]);
|
|
|
+ info_info->status = atoi(pResult[ncol+1]);
|
|
|
+ strcpy(info_info->secret_id, pResult[ncol+2]);
|
|
|
+ strcpy(info_info->secret_key, pResult[ncol+3]);
|
|
|
+ strcpy(info_info->url, pResult[ncol+4]);
|
|
|
+ strcpy(info_info->app_id, pResult[ncol+5]);
|
|
|
+ strcpy(info_info->signature, pResult[ncol+6]);
|
|
|
+ strcpy(info_info->template, pResult[ncol+7]);
|
|
|
+ strcpy(info_info->country_code, pResult[ncol+8]);
|
|
|
+ strcpy(info_info->region, pResult[ncol+9]);
|
|
|
+ }
|
|
|
+ ////////////////////////////////////////////////////////////////////////
|
|
|
+
|
|
|
+ table = TENCENT_CLOUD_SMS_PHONE;
|
|
|
+ if(!tab_exists(db, table)) {
|
|
|
+ sprintf(temp, "CREATE TABLE IF NOT EXISTS %s("
|
|
|
+ "id INTEGER PRIMARY KEY,"
|
|
|
+ "phonenumber TEXT);", table);
|
|
|
+ r = sqlite3_exec(db, temp, 0, 0, &err_msg);
|
|
|
+ if(r!=SQLITE_OK) {
|
|
|
+ log_e("___ %s create failed, %s\n%s\n", table, temp, err_msg); sqlite3_free(err_msg);
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ nrow = ncol = 0;
|
|
|
+ sprintf(temp, "SELECT * FROM %s;", table);
|
|
|
+ r = sqlite3_get_table(db, temp, &pResult, &nrow, &ncol, &err_msg);
|
|
|
+ if(r != SQLITE_OK) {
|
|
|
+ log_e("sqlite handle error: %s \n%s\n", temp, err_msg); sqlite3_free(err_msg);
|
|
|
+ return -1 ;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(info && ncol>0) {
|
|
|
+ tencent_cloud_phone_t *phone_info=&info->phone;
|
|
|
+ for(i=1; i<=nrow; i++) {
|
|
|
+ phone_info->phone[i-1].id = atoi(pResult[i*ncol+0]);
|
|
|
+ strcpy(phone_info->phone[i-1].phone, pResult[i*ncol+1]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sqlite3_free_table(pResult);
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+/*typedef struct
|
|
|
+{
|
|
|
+ char secret_id[64];
|
|
|
+ char secret_key[64];
|
|
|
+ char url[64];
|
|
|
+ char app_id[64];
|
|
|
+ char signature[64];
|
|
|
+}tencent_cloud_info_t;
|
|
|
+*/
|
|
|
+int dev_tencent_cloud_init(sqlite3 *db, cloud_info_t *info)
|
|
|
+{
|
|
|
+ int i,r=-1;
|
|
|
+ char temp[1024];
|
|
|
+ char *err_msg=NULL;
|
|
|
+ char *table=NULL;
|
|
|
+ int nrow,ncol;
|
|
|
+ char** pResult = NULL;
|
|
|
+ table = TENCENT_CLOUD_SMS_INFO_TABLE;
|
|
|
+
|
|
|
+ if(!tab_exists(db, table))
|
|
|
+ {
|
|
|
+ sprintf(temp, "CREATE TABLE IF NOT EXISTS %s("
|
|
|
+ "id INTEGER PRIMARY KEY,"
|
|
|
+ "status INTEGER,"
|
|
|
+ "secretId INTEGER,"
|
|
|
+ "secretKey TEXT,"
|
|
|
+ "url TEXT,"
|
|
|
+ "appid TEXT,"
|
|
|
+ "signature TEXT,"
|
|
|
+ "template TEXT,"
|
|
|
+ "countryCode TEXT,"
|
|
|
+ "region TEXT;", table);
|
|
|
+ r = sqlite3_exec(db, temp, 0, 0, &err_msg);
|
|
|
+ if(r!=SQLITE_OK) {
|
|
|
+ log_e("___ %s create failed, %s\n%s\n", table, temp, err_msg); sqlite3_free(err_msg);
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ extern tencent_cloud_info_t DFLT_TENCENT_CLOUD_INFO;
|
|
|
+ dev_tencent_cloud_update_info(db, &DFLT_TENCENT_CLOUD_INFO);
|
|
|
+ }
|
|
|
+ table = TENCENT_CLOUD_SMS_PHONE;
|
|
|
+ if(!tab_exists(db, table))
|
|
|
+ {
|
|
|
+ sprintf(temp, "CREATE TABLE IF NOT EXISTS %s("
|
|
|
+ "id INTEGER PRIMARY KEY,"
|
|
|
+ "phonenumber TEXT,", table);
|
|
|
+ r = sqlite3_exec(db, temp, 0, 0, &err_msg);
|
|
|
+ if(r!=SQLITE_OK) {
|
|
|
+ log_e("___ %s create failed, %s\n%s\n", table, temp, err_msg); sqlite3_free(err_msg);
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ r = dev_tencent_cloud_get(db, info);
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
int dev_mail_init(sqlite3 *db, mail_info_t *info)
|
|
|
{
|
|
|
int i,r=-1;
|
|
|
@@ -4975,6 +5115,69 @@ int dev_mail_init(sqlite3 *db, mail_info_t *info)
|
|
|
}
|
|
|
|
|
|
|
|
|
+int dev_tencent_cloud_update_info(sqlite3 *db, tencent_cloud_info_t *info)
|
|
|
+{
|
|
|
+ int i,r=-1,exist=0,cnt=0;
|
|
|
+
|
|
|
+#ifdef USE_MAIL
|
|
|
+ char temp[9216];
|
|
|
+ sqlite3_stmt *stmt;
|
|
|
+ char *err_msg=NULL;
|
|
|
+ char *table=TENCENT_CLOUD_SMS_INFO_TABLE;
|
|
|
+
|
|
|
+ cnt = get_count(db, table);
|
|
|
+ if(cnt>0) {
|
|
|
+ sprintf(temp, "UPDATE %s SET id=%d,status=%d,secretId='%s',secretKey='%s',url='%s',appid='%s',siqnature='%s',template='%s',countryCode='%s' WHERE id=%d;",
|
|
|
+ table, info->id,info->status,info->secret_id,info->secret_key,info->url,info->app_id,info->signature,info->template,info->country_code,info->id);
|
|
|
+ r = sqlite3_exec(db, temp, NULL, 0, &err_msg);
|
|
|
+ if(r != SQLITE_OK) {
|
|
|
+ log_e("dev_tencent_cloud_update_info failed, %s, %s\n\n", temp, err_msg);
|
|
|
+ sqlite3_free(err_msg);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ exist = sqlite3_changes(db);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(exist==0) {
|
|
|
+ sprintf(temp, "INSERT INTO %s (id,status,secretId,secretKey,url,appid,siqnature,template,countryCode) VALUES (?,?,?,?,?,?,?,?,?);", table);
|
|
|
+ r = sqlite3_prepare_v2(db, temp, -1, &stmt, 0);
|
|
|
+ if (r != SQLITE_OK) {
|
|
|
+ log_e("dev_tencent_cloud_update_info, sqlite3_prepare_v2 failed, %s\n", sqlite3_errmsg(db));
|
|
|
+ r = -1; goto quit;
|
|
|
+ }
|
|
|
+
|
|
|
+ sqlite3_bind_int(stmt, 1, info->id);
|
|
|
+ sqlite3_bind_int(stmt, 2, info->status);
|
|
|
+ sqlite3_bind_text(stmt, 3, info->secret_id, -1, NULL);
|
|
|
+ sqlite3_bind_text(stmt, 4, info->secret_key, -1, NULL);
|
|
|
+ sqlite3_bind_text(stmt, 5, info->url, -1, NULL);
|
|
|
+ sqlite3_bind_text(stmt, 6, info->app_id, -1, NULL);
|
|
|
+ sqlite3_bind_text(stmt, 7, info->signature, -1, NULL);
|
|
|
+ sqlite3_bind_text(stmt, 8, info->template, -1, NULL);
|
|
|
+ sqlite3_bind_text(stmt, 9, info->country_code, -1, NULL);
|
|
|
+ sqlite3_bind_text(stmt, 10, info->region, -1, NULL);
|
|
|
+
|
|
|
+ r = sqlite3_step(stmt);
|
|
|
+ sqlite3_finalize(stmt);
|
|
|
+
|
|
|
+ if (r != SQLITE_DONE) {
|
|
|
+ log_e("dev_tencent_cloud_update_info, sqlite3_step failed\n");
|
|
|
+ r = -1;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ r = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+quit:
|
|
|
+#endif
|
|
|
+
|
|
|
+ return r;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
int dev_mail_update_send(sqlite3 *db, mail_send_t *send)
|
|
|
{
|
|
|
int i,r=-1,exist=0,cnt=0;
|
|
|
@@ -5033,6 +5236,62 @@ quit:
|
|
|
return r;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+int dev_tencent_cloud_update_phone(sqlite3 *db, phone_id_t *phone)
|
|
|
+{
|
|
|
+ int i,r=-1,exist=0,cnt=0;
|
|
|
+
|
|
|
+ char temp[1024];
|
|
|
+ sqlite3_stmt *stmt;
|
|
|
+ char *err_msg=NULL;
|
|
|
+ phone_id_t *ph=NULL;
|
|
|
+ char *table=TENCENT_CLOUD_SMS_PHONE;
|
|
|
+
|
|
|
+ if(!db || !phone) {
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ cnt = get_count(db, table);
|
|
|
+ for(i=0; i<20; i++) {
|
|
|
+ ph = &phone[i];
|
|
|
+ if(cnt>0) {
|
|
|
+ sprintf(temp, "UPDATE %s SET id=%d, phoneNumber='%s', WHERE id=%d;",
|
|
|
+ table, phone->id, phone->phone, phone->id);
|
|
|
+ r = sqlite3_exec(db, temp, NULL, 0, &err_msg);
|
|
|
+ if(r != SQLITE_OK) {
|
|
|
+ log_e("dev_cloud_update_phone failed, %s, %s\n", temp, err_msg);
|
|
|
+ sqlite3_free(err_msg);
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ exist = sqlite3_changes(db);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(exist==0) {
|
|
|
+ sprintf(temp, "INSERT INTO %s (id,phoneNumber) VALUES (?,?);", table);
|
|
|
+ r = sqlite3_prepare_v2(db, temp, -1, &stmt, 0);
|
|
|
+ if (r != SQLITE_OK) {
|
|
|
+ log_e("dev_cloud_update_phone, sqlite3_prepare_v2 failed, %s\n", sqlite3_errmsg(db));
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ sqlite3_bind_int(stmt, 1, ph->id);
|
|
|
+ sqlite3_bind_text(stmt, 2, ph->phone, -1, NULL);
|
|
|
+
|
|
|
+ r = sqlite3_step(stmt);
|
|
|
+ sqlite3_finalize(stmt);
|
|
|
+
|
|
|
+ if (r != SQLITE_DONE) {
|
|
|
+ log_e("dev_cloud_update_phone, sqlite3_step failed\n");
|
|
|
+ r = -1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return r;
|
|
|
+}
|
|
|
+
|
|
|
int dev_mail_update_recv(sqlite3 *db, mail_recv_t *recv)
|
|
|
{
|
|
|
int i,r=-1,exist=0,cnt=0;
|