コード例 #1
0
void getsavedhotielist(void *arg)//
{
	Value root;
	Reader reader;
	struct user * puser = (struct user*)arg;
	pthread_mutex_lock(&(puser->msg_lock));
	string data = puser->data;
	pthread_mutex_unlock(&(puser->msg_lock));
	if (reader.parse(data, root))
	{
		Value object,list, item;
		FastWriter writer;
		string username = root["username"].asString();
		int num = root["num"].asInt();
		//struct hottielist* hotlist = myhottie(writ, num);
		int ret_len;
		struct collection* pcollect = show_collect(username,num,ret_len); 
		for(int i=0;i<ret_len;++i)
		{
			item["title"] = pcollect[i].title;
			item["writer"] = pcollect[i].author;
			list.append(item);
		}
		object["typecode"] = 2110;
		object["list"] = list;
		string strdata = writer.write(object);
		pthread_mutex_lock(&(puser->msg_lock));
		puser->msg.push_back(strdata);
		pthread_mutex_unlock(&(puser->msg_lock));
		delete[] pcollect;
	}
}
コード例 #2
0
void getonehottie(void *arg)//0
{
	Value root;
	Reader reader;
	struct user * puser = (struct user*)arg;
	pthread_mutex_lock(&(puser->msg_lock));
	string data = puser->data;
	pthread_mutex_unlock(&(puser->msg_lock));
	if (reader.parse(data, root))
	{
		Value object;
		FastWriter writer;
		string title = root["title"].asString();
		string wri = root["writer"].asString();
		struct hottie *p_hottie = onehottie(wri, title); 	
		object["typecode"] = 2090;
		object["content"] = p_hottie->text;
		object["title"] =  p_hottie->title;
		object["img"] =  p_hottie->picture;

		string strdata = writer.write(object);
		pthread_mutex_lock(&(puser->msg_lock));
		puser->msg.push_back(strdata);
		pthread_mutex_unlock(&(puser->msg_lock));
	
		free(p_hottie);
	}

}
コード例 #3
0
void createqun(void *arg)//0
{
	Value root;
	Reader reader;
	struct user * puser = (struct user*)arg;
	pthread_mutex_lock(&(puser->msg_lock));
	string data = puser->data;
	pthread_mutex_unlock(&(puser->msg_lock));
	if (reader.parse(data, root))
	{
		Value object;
		FastWriter writer;
		string username = root["username"].asString();
		string groupname = root["group_name"].asString();
		int img = root["img"].asInt();
		cout<<"img"<<img<<endl;
		string infor = root["group_infor"].asString();

		//call dbfunction():
		cout << "group infor:"<< infor << endl;
		int ret = createqun(groupname, username, img, infor); //attention the type of qunportrait.
		if (ret == 1)
		{
			object["typecode"] = 1310;
			object["group_name"] = groupname;
		}
		else
			object["typecode"] = 1311;

		string strdata = writer.write(object);
		pthread_mutex_lock(&(puser->msg_lock));
		puser->msg.push_back(strdata);
		pthread_mutex_unlock(&(puser->msg_lock));
	}
}
コード例 #4
0
void finishgame(void *arg)
{
	struct user* puser = (struct user*)arg;
	Value object, object1;
	FastWriter writer;
	struct user* prival = puser->prival;
	object["typecode"] = 3013;
	object["winner"] = puser->username;
	string strdata = writer.write(object);

	int tatol = add_scores(puser->username,30);
	object1["typecode"] = 4010;
	object1["score"] = tatol;
	string strdata1 = writer.write(object1);

	pthread_mutex_lock(&(puser->msg_lock));
	puser->msg.push_back(strdata);
	puser->msg.push_back(strdata1);
	pthread_mutex_unlock(&(puser->msg_lock));
	//puser->prival = NULL;

	tatol = add_scores(prival->username,15);
	object1["score"] = tatol;
 	strdata1 = writer.write(object1);

	pthread_mutex_lock(&(prival->msg_lock));
	prival->msg.push_back(strdata);
	prival->msg.push_back(strdata1);
	pthread_mutex_unlock(&(prival->msg_lock));
	//prival->prival = NULL;
}
コード例 #5
0
ファイル: TCPServer.cpp プロジェクト: flyingtime/boxee
void CTCPServer::Announce(ANNOUNCEMENT::EAnnouncementFlag flag, const char *sender, const char *message, const CVariant &data)
{
  Value root;
  root["jsonrpc"] = "2.0";
  root["method"]  = "Announcement";
  root["params"]["sender"] = sender;
  root["params"]["message"] = message;
  if (!data.isNull())
    data.toJsonValue(root["params"]["data"]);

  FastWriter writer;
  //StyledWriter writer;
  std::string str = writer.write(root);

  for (unsigned int i = 0; i < m_connections.size(); i++)
  {
    {
      CSingleLock lock (m_connections[i].m_critSection);
      if ((m_connections[i].GetAnnouncementFlags() & flag) == 0)
        continue;
    }

    unsigned int sent = 0;
    do
    {
      CSingleLock lock (m_connections[i].m_critSection);
      sent += send(m_connections[i].m_socket, str.c_str(), str.size() - sent, sent);
    } while (sent < str.size());
  }
}
コード例 #6
0
void serqun(void *arg)//
{
	Value root;
	Reader reader;
	struct user * puser = (struct user*)arg;
	pthread_mutex_lock(&(puser->msg_lock));
	string data = puser->data;
	pthread_mutex_unlock(&(puser->msg_lock));
	if(reader.parse(data,root))
	{
		Value object;
		FastWriter writer;
		string groupname = root["group_name"].asString();
		struct quninfor* pgroup = searchqun(groupname);
		object["typecode"] = 1130;
		object["group_name"] = pgroup->qunname;
		object["img"] = pgroup->qunportrait;
		object["infor"] = pgroup->qundescrible;
		string strdata = writer.write(object);
		pthread_mutex_lock(&(puser->msg_lock));
		puser->msg.push_back(strdata);
		pthread_mutex_unlock(&(puser->msg_lock));
		delete pgroup;
	}
}
コード例 #7
0
void getfanslist(void *arg)//
{
	Value root;
	Reader reader;
	struct user * puser = (struct user*)arg;
	pthread_mutex_lock(&(puser->msg_lock));
	string data = puser->data;
	pthread_mutex_unlock(&(puser->msg_lock));
	if(reader.parse(data,root))
	{
		Value object,flist,item;
		FastWriter writer;
		string username = root["username"].asString();
		int num = root["num"].asInt();
		struct fanslist* list = show_fans(username, num);
		int len = list->Isquerysuccess;
		for(int i=0;i<len;++i)
		{
			item["img"] = list->pfanslist[i].portrait;
			item["name"] = list->pfanslist[i].username;
			flist.append(item);
		}
		object["typecode"] = 0650;
		object["focused"] = flist;
		string strdata = writer.write(object);
		pthread_mutex_lock(&(puser->msg_lock));
		puser->msg.push_back(strdata);			//add data to send vector
		pthread_mutex_unlock(&(puser->msg_lock));
		delete[] list->pfanslist;
		delete list;
	}	
}
コード例 #8
0
ファイル: Capture.cpp プロジェクト: kumarrishav/silk
  /**
   * Notify the client of a capture event
   */
  void sendEvent(const Value & jsonMsg) {
    FastWriter fastWriter;
    string jsonMessage = fastWriter.write(jsonMsg);

    ALOGV("Broadcasting %s", jsonMessage.c_str());
    FrameworkListener1::sendBroadcast(200, jsonMessage.c_str(), false);
  }
コード例 #9
0
void tofocus(void *arg)//
{
	Value root;
	Reader reader;
	struct user * puser = (struct user*)arg;
	pthread_mutex_lock(&(puser->msg_lock));
	string data = puser->data;
	pthread_mutex_unlock(&(puser->msg_lock));
	if(reader.parse(data,root))
	{
		string username = root["username"].asString();
		string focused = root["focused"].asString();
		int num = 0;
		if(add_focus(username, focused, num) == 1)
		{
			Value object;
			FastWriter writer;
			object["typecode"] = 610;
			object["num"] = num;
			string strdata = writer.write(object);
			pthread_mutex_lock(&(puser->msg_lock));
			puser->msg.push_back(strdata);			//add data to send vector
			pthread_mutex_unlock(&(puser->msg_lock));
		}
	}
}
コード例 #10
0
void createhottie(void *arg)//0
{
	Value root;
	Reader reader;
	struct user * puser = (struct user*)arg;
	pthread_mutex_lock(&(puser->msg_lock));
	string data = puser->data;
	pthread_mutex_unlock(&(puser->msg_lock));
	if(reader.parse(data,root))
	{
		Value object;
		FastWriter writer;
		string title = root["title"].asString();
		string text = root["content"].asString();
		int  picID = root["img"].asInt();
		string author = root["username"].asString();

		//call dbfunction():
		int ret =insert_hottie(picID, author, title, text); //where is the input parameter?
		if(ret == 1)
		{
			object["typecode"] = 2010;
		}
		else
		{
			object["typecode"] = 2011;
		}
		object["title"] = title;
	
		string strdata = writer.write(object);
		pthread_mutex_lock(&(puser->msg_lock));
		puser->msg.push_back(strdata);
		pthread_mutex_unlock(&(puser->msg_lock));
	}
}
コード例 #11
0
void getprivatehottielist(void *arg)//0
{
	Value root;
	Reader reader;
	struct user * puser = (struct user*)arg;
	pthread_mutex_lock(&(puser->msg_lock));
	string data = puser->data;
	pthread_mutex_unlock(&(puser->msg_lock));
	if (reader.parse(data, root))
	{
		Value object,list, item;
		FastWriter writer;
		string writ = root["writer"].asString();
		int num = root["num"].asInt();
		struct hottielist* hotlist = myhottie(writ, num);
		int len = hotlist->Isquerysuccess;
		//cout<<"len:"<<len<<endl;
		for(int i=0;i<len;++i)
		{
			item["title"] = hotlist->phottielist[i].title;
			item["img"] = hotlist->phottielist[i].picture;
			list.append(item);
		}
		object["writer"] = writ;
		object["typecode"] = 2050;
		object["list"] = list;
		string strdata = writer.write(object);
		pthread_mutex_lock(&(puser->msg_lock));
		puser->msg.push_back(strdata);
		pthread_mutex_unlock(&(puser->msg_lock));
		delete[] hotlist->phottielist;
		delete hotlist;
	}
}
コード例 #12
0
TEST_F(JsonCpp, FastWriter) {
	for (int i = 0; i < kTrialCount; i++) {
		FastWriter writer;
		std::string str = writer.write(root_);
		//if (i == 0)
		//	std::cout << str.length() << std::endl;
	}
}
コード例 #13
0
ファイル: JSONElement.cpp プロジェクト: AgrimPrasad/Unlogo
//--------------------------------------------------------------
string JSONElement::getRawString(bool pretty) {
	string raw;
	if(pretty) {
		StyledWriter writer;
		raw = writer.write(*this);
	} else {
		FastWriter writer;
		raw = writer.write(*this);
	}
	return raw;
}
コード例 #14
0
/*************************************TcpClient::clientMsg*********************************************/
string TcpClient::clientMsg() {
	Value RequestLocation;
	FastWriter writer;
	RequestLocation["typecode"] = 1040;
	RequestLocation["rssi"] =
			"74:ea:3a:26:10:86,-92.0;20:dc:e6:6b:36:10,-86.0;30:49:3b:09:68:25,-67.14492753623189;50:bd:5f:06:72:84,-85.95;00:87:36:07:ef:4d,-79.70689655172414;30:49:3b:09:68:27,-52.971014492753625;d8:15:0d:38:5b:4e,-62.68115942028985;30:49:3b:09:6b:49,-78.08695652173913;30:49:3b:09:6a:45,-85.0925925925926;08:10:74:67:63:1a,-92.16666666666667;38:83:45:96:c7:6c,-64.4927536231884;44:2b:03:8b:80:c8,-55.82608695652174;38:83:45:47:51:84,-87.0754716981132;c8:3a:35:3f:4d:98,-84.32075471698113;74:ea:3a:2f:6d:0a,-64.7536231884058;e4:d3:32:e3:fc:38,-87.66666666666667;30:49:3b:09:6a:4f,-73.05084745762711;e4:d3:32:eb:f9:f2,-90.0;b0:48:7a:5d:f3:28,-35.57971014492754;5c:63:bf:37:27:6c,-75.08823529411765;e0:05:c5:b3:d3:9e,-88.26666666666667;30:49:3b:09:6a:4b,-87.85714285714286;78:a1:06:fd:41:84,-86.37037037037037;30:49:3b:09:6a:59,-89.54545454545455;20:dc:e6:88:5b:5e,-89.57142857142857;20:dc:e6:6d:13:0e,-77.61764705882354;00:23:cd:83:7d:a0,-90.0;30:49:3b:09:6b:4b,-85.91304347826087";
#if BURDEN_ANALY
	RequestLocation["timestamp"] = htonl(time(NULL));
#endif
	//cout << RequestLocation << endl;
	return writer.write(RequestLocation);
}
コード例 #15
0
ファイル: TagDB.cpp プロジェクト: mappcenter/lazyboys-pro
string TagDB::convertTagToJson(Tag& tag) {
    Json::Value value;
    value["tagName"] = tag.tagName;
    value["viewCounts"] = static_cast<int> (tag.viewCounts);
    value["dateAdd"] = tag.dateAdd;
    value["dateUpdate"] = tag.dateUpdate;
    //Json::StyledWriter writer;
    FastWriter writer;
    string jsonText = writer.write(value);
    //poco_information_f1(*logger, "convertTagToJson: Convert from Tag %s to json successful", tag.tagID);
    return jsonText;
}
コード例 #16
0
void respaddqun(void *arg)
{
	Value root;
	Reader reader;
	struct user * puser = (struct user*)arg;
	pthread_mutex_lock(&(puser->msg_lock));
	string data = puser->data;
	pthread_mutex_unlock(&(puser->msg_lock));
	if(reader.parse(data,root))
	{	
		Value object;
		FastWriter writer;
		string requester = root["requester"].asString();
		string master = root["master"].asString();
		string qunname = root["group_name"].asString();
		int typecode = root["typecode"].asInt();
		int groupid;
		if(typecode == 1601)	//agree to add qun
		{
			long pmaster = responsejoin(1, requester, qunname);
			struct user* puser = (struct user*)pmaster;
			object["typecode"] = 1070;
			object["group_name"] = qunname;			
			object["master"] = master;			

			string strdata = writer.write(object);
			pthread_mutex_lock(&(puser->msg_lock));
			puser->msg.push_back(strdata);			//add data to send vector
			pthread_mutex_unlock(&(puser->msg_lock));
			
		}
		else if(typecode == 1602)
		{
			long pmaster = responsejoin(0, requester, qunname);
			struct user* puser = (struct user*)pmaster;

			object["typecode"] = 1071;
			object["group_name"] = qunname;			
			object["master"] = master;			

			string strdata = writer.write(object);
			pthread_mutex_lock(&(puser->msg_lock));
			puser->msg.push_back(strdata);			//add data to send vector
			pthread_mutex_unlock(&(puser->msg_lock));			
		}
	
	}	
}
コード例 #17
0
ファイル: JSONElement.cpp プロジェクト: AgrimPrasad/Unlogo
//--------------------------------------------------------------
bool JSONElement::save(string filename, bool pretty)
{
	ofstream file_key(filename.c_str());
	if (!file_key.is_open()) {
		cout << "Unable to open " << filename << endl;
		return false;
	}
	
	if(pretty) {
		StyledWriter writer;
		file_key << writer.write( *this ) << endl;
	} else {
		FastWriter writer;
		file_key << writer.write( *this ) << endl;
	}
	file_key.close();	
	return true;
}
コード例 #18
0
ファイル: ItemDB.cpp プロジェクト: mappcenter/lazyboys-pro
/**
 * Ham ma hoa 1 Item thanh chuoi Json, khong ma hoa itemID.
 * @param item
 * @return string
 */
string ItemDB::convertItemToJson(Item& item) {

    Value value;
    value["content"] = item.content;
    value["tagsID"];
    int n = item.tagsID.size();
    for (int i = 0; i < n; i++) {
        value["tagsID"][i] = item.tagsID[i];
    }
    value["likeCounts"] = static_cast<int> (item.likeCounts);
    value["viewCounts"] = static_cast<int> (item.viewCounts);
    value["dislikeCounts"] = static_cast<int> (item.dislikeCounts);
    value["dateAdd"] = item.dateAdd;
    value["dateUpdate"] = item.dateUpdate;
    FastWriter writer; //not use Json::Writer because it is a virtual class
    string jsonString = writer.write(value);
    return jsonString;
}
コード例 #19
0
void askpk(void *arg)//
{
	Value root;
	Reader reader;
	struct user * puser = (struct user*)arg;
	pthread_mutex_lock(&(puser->msg_lock));
	string data = puser->data;
	pthread_mutex_unlock(&(puser->msg_lock));
	if (reader.parse(data, root))
	{
		Value object;
		FastWriter writer;
		string username = root["username"].asString();
		puser->username = username;
		if(privalUser == NULL)
		{
			privalUser = puser;
			object["typecode"] = 3010;
			string strdata = writer.write(object);
			pthread_mutex_lock(&(puser->msg_lock));
			puser->msg.push_back(strdata);
			pthread_mutex_unlock(&(puser->msg_lock));
		}
		else if(puser != privalUser)
		{
			puser->prival = privalUser;
			object["typecode"] = 3011;
			object["rivalname"] = privalUser->username;
			string strdata = writer.write(object);
			pthread_mutex_lock(&(puser->msg_lock));
			puser->msg.push_back(strdata);
			pthread_mutex_unlock(&(puser->msg_lock));
			
			privalUser->prival = puser;
			object["rivalname"] = puser->username;
			strdata = writer.write(object);
			pthread_mutex_lock(&(privalUser->msg_lock));
			privalUser->msg.push_back(strdata);
			pthread_mutex_unlock(&(privalUser->msg_lock));

			privalUser = NULL;
		}
	}
}
コード例 #20
0
//--------------------------------------------------------------
bool ofxJSONElement::save(string filename, bool pretty)
{
	filename = ofToDataPath(filename, true);
	ofstream file_key(filename.c_str());
	if (!file_key.is_open()) {
		ofLog(OF_LOG_WARNING, "Unable to open "+filename);
		return false;
	}
	
	if(pretty) {
		StyledWriter writer;
		file_key << writer.write( *this ) << endl;
	} else {
		FastWriter writer;
		file_key << writer.write( *this ) << endl;
	}
	ofLog(OF_LOG_NOTICE, "JSON saved to "+filename);
	file_key.close();	
	return true;
}
コード例 #21
0
void chat(void *arg)//
{
	Value root;
	Reader reader;
	struct user * puser = (struct user*)arg;
	pthread_mutex_lock(&(puser->msg_lock));
	string data = puser->data;
	pthread_mutex_unlock(&(puser->msg_lock));
	if (reader.parse(data, root))
	{
		Value object;
		FastWriter writer;
		string username = root["username"].asString();
		string qunname = root["group_name"].asString();
		string msg = root["msg"].asString();
		long *pointer;
		long num = 0;
		addchatrecord(username, qunname, msg, pointer,num);
cout<<"num:"<<num<<endl;
cout<<"*pointeer:"<<pointer[0]<<endl;
		for(int i=0;i<num;++num)
		{
			struct user* puser = (struct user*)pointer[i];
			if(i == num-1)
				delete pointer;
			Value object;
			object["typecode"] = 1200;
			object["username"] = username;
			object["group_name"] = qunname;
			object["msg"] = msg;

			string strdata = writer.write(object);
			cout << "huibuhui baocuo" << endl;
			pthread_mutex_lock(&(puser->msg_lock));
			puser->msg.push_back(strdata);
			pthread_mutex_unlock(&(puser->msg_lock));
		}
		//delete pointer;
	}
}
コード例 #22
0
void quitqun(void *arg)//
{
	Value root,object;
	Reader reader;
	FastWriter writer;
	struct user * puser = (struct user*)arg;
	pthread_mutex_lock(&(puser->msg_lock));
	string data = puser->data;
	pthread_mutex_unlock(&(puser->msg_lock));
	if(reader.parse(data,root))
	{
		string username = root["username"].asString();
		string groupname = root["group_name"].asString(); 
		outofgroup(username, groupname);
		object["typecode"] = 1040;
		object["group_name"] = groupname; 
		string strdata = writer.write(root);
		pthread_mutex_lock(&(puser->msg_lock));
		puser->msg.push_back(strdata);			//add data to send vector
		pthread_mutex_unlock(&(puser->msg_lock));
	}
}
コード例 #23
0
void quitgame(void *arg)
{
	struct user * puser = (struct user*)arg;
	Value object, object1;
	FastWriter writer;
	struct user* prival = puser->prival;
	object["typecode"] = 3012;
	object["rivalname"] = puser->username;
	string strdata = writer.write(object);
	pthread_mutex_lock(&(prival->msg_lock));
	prival->msg.push_back(strdata);
	pthread_mutex_unlock(&(prival->msg_lock));
	
	int tatol = add_scores(puser->username,-5);
	object1["typecode"] = 4010;
	object1["score"] = tatol;
	strdata = writer.write(object1);
	pthread_mutex_lock(&(puser->msg_lock));
	puser->msg.push_back(strdata);
	pthread_mutex_unlock(&(puser->msg_lock));

}
コード例 #24
0
void getqunrecord(void *arg)//
{
	Value root;
	Reader reader;
	struct user * puser = (struct user*)arg;
	pthread_mutex_lock(&(puser->msg_lock));
	string data = puser->data;
	pthread_mutex_unlock(&(puser->msg_lock));
	if (reader.parse(data, root))
	{
		Value object, recordlist, item;
		FastWriter writer;
		string groupname = root["group_name"].asString();
		string username = root["username"].asString();
		int num = root["num"].asInt();
		
		struct recordlist* qunrcd = showchatrcd(username, groupname,num); //!should input the username
		int len = qunrcd->Isquerysuccess;
		struct RECORD* precord = qunrcd->precordlist;
		for(int i=0; i<len; ++i)
		{
			item["username"] = precord[i].username;
			item["msg"] = precord[i].message;
			item["time"] = precord[i].cur_time;
			item["img"] = precord[i].usrportrt; //add in the dbhandle.cpp.
			recordlist.append(item);
		}
			object["typecode"] = 1220;
			object["group_name"] = groupname; //qunname is above
			object["recordlist"] = recordlist;
			string strdata = writer.write(object);
			pthread_mutex_lock(&(puser->msg_lock));
			puser->msg.push_back(strdata);
			pthread_mutex_unlock(&(puser->msg_lock));
		
		delete[] precord;
		delete qunrcd;
	}
}
コード例 #25
0
void addfen(void*arg)
{
	Value root;
	Reader reader;
	struct user * puser = (struct user*)arg;
	pthread_mutex_lock(&(puser->msg_lock));
	string data = puser->data;
	pthread_mutex_unlock(&(puser->msg_lock));
	if (reader.parse(data, root))
	{
		Value object;
		FastWriter writer;
		string username = root["username"].asString();

		int tatol = add_scores(username,10);
		object["typecode"] = 4010;
		object["score"] = tatol;
		string strdata = writer.write(object);
		pthread_mutex_lock(&(puser->msg_lock));
		puser->msg.push_back(strdata);
		pthread_mutex_unlock(&(puser->msg_lock));
	}	
}
コード例 #26
0
void addqun(void *arg)//
{
	Value root;
	Reader reader;
	struct user * puser = (struct user*)arg;
	pthread_mutex_lock(&(puser->msg_lock));
	string data = puser->data;
	pthread_mutex_unlock(&(puser->msg_lock));
	if(reader.parse(data,root))
	{	
		Value object;
		FastWriter writer;
		string requester = root["requester"].asString();
		string qunname = root["group_name"].asString();
		int groupid;
		long pmaster = requestjoin(requester, qunname, groupid);
		if(pmaster == -1)	//qunmaster is offline
		{
			object["typecode"] = 1073;
			cout<<"qunmaster is offlime"<<endl;
		}
		else 
		{
			object["typecode"] = 1070;
			object["group_name"] = qunname;			
			object["requester"] = requester;			
			puser = (struct user*)pmaster;
		}

		string strdata = writer.write(object);
		pthread_mutex_lock(&(puser->msg_lock));
		puser->msg.push_back(strdata);			//add data to send vector
		pthread_mutex_unlock(&(puser->msg_lock));
	
	}
}
コード例 #27
0
void savehottie(void *arg)//0
{
	Value root;
	Reader reader;
	struct user * puser = (struct user*)arg;
	pthread_mutex_lock(&(puser->msg_lock));
	string data = puser->data;
	pthread_mutex_unlock(&(puser->msg_lock));
	if (reader.parse(data, root))
	{
		Value object;
		FastWriter writer;
		string username = root["username"].asString();
		string title = root["title"].asString();
		add_collect(username,title);
		object["typecode"] = 2070;
		object["title"] = title;
		string strdata = writer.write(object);
		pthread_mutex_lock(&(puser->msg_lock));
		puser->msg.push_back(strdata);
		pthread_mutex_unlock(&(puser->msg_lock));
		
	}
}
コード例 #28
0
ファイル: CMSUtils.cpp プロジェクト: ohosrry/cmsupload
BSTR CCMSUtils::doGetDriveFiles(void)
{
	USES_CONVERSION;
	INT drive_current=0;
	ULONG uDriveMask=0;
	INT drive=1;
	INT last=0;
	Value root;
	Value images;
	Reader reader;
	FastWriter fw;
	string retStr;
	TCHAR g_szDrvMsg[] = _T("A:\\");
	static char drive_buff[_MAX_PATH]={0};
	drive_current = _getdrive();
	string drive_str;
	uDriveMask=_getdrives();
	if(uDriveMask==0){
		CMSBOXW(L"º¯Êý·µ»ØûÓдÅÅÌ");
	}else{
		while(uDriveMask)
		{
			if(uDriveMask&1)
			{
				Value lv;
				Value image;
				Value lnone;
				char *path_files=NULL;
				path_files=W2A(doGetPathFiles(g_szDrvMsg));
				if(NULL!=path_files&&reader.parse(path_files,lv)==TRUE)
				{
					if(lv.isMember("images"))
					{
						Value::iterator it=lv["images"].begin();

						while(it!=lv["images"].end())
					 {   

						 images.append(*it);
						 ++it;
					 }

				 }
					root[W2A(g_szDrvMsg)]=lv;
				}
			}
			++g_szDrvMsg[0];
			uDriveMask >>= 1;
		}
	}
	//for(;drive<=26;++drive)
	//{
	// if(!_chdrive(drive))
	// {
	//  if( _getdcwd( drive, drive_buff, _MAX_PATH ) != NULL ){
	//   CString  files=doGetPathFiles(A2W(drive_buff));
	//           // files.Replace(L"\\\\",L"\\");
	//   drive_str+=drive_buff;
	//   root[drive_buff]=W2A(files);
	//  }
	// }
	//}
	//_chdrive( drive_current );
	if(images.isArray()&&images.size()>=1)
	{
		root["images"]=images;
	}
	retStr=fw.write(root);
	CString cs(A2W(retStr.c_str()));
	//cs.Replace(L"\\\\",L"\\");
	//CMSBOXW(cs);
	cs.Replace(L"\\n",L"");
	if(cs.GetLength()>0)
	{ 
		/*   CMSBOXW(cs);
		CMSBOX(drive_str.c_str());*/
		return cs.AllocSysString();
	}
	//if(GetLogicalDriveStrings(1024,drive_buff)!=0){
	//   CMSBOXW(drive_buff);
	//}
	return NULL;
}
コード例 #29
0
ファイル: CMSUtils.cpp プロジェクト: ohosrry/cmsupload
BSTR CCMSUtils::doGetPathFiles(BSTR path_name)
{
	USES_CONVERSION;
	Value root;
	FastWriter fw;
	string retStr;
	CString pattern(path_name);
	pattern+=L"\\*.*";
	//CMSBOXW(pattern);
	Value images;
	int dir_index=0;
	int image_index=0;
	CString res;
	if(NULL!=path_name&&_file_exists(W2A(path_name))==0)
	{
		SetCurrentDirectory(path_name);
		CFileFind cff;
		BOOL found=cff.FindFile(pattern);
		while(found)
		{   
			found=cff.FindNextFile();
			//res+=L"  "+cff.GetFilePath();
			if(cff.IsDirectory()&&!cff.IsDots()){
				CString full_path=cff.GetFilePath();
				//full_path.Append(cff.GetFileName());
				if(!full_path.IsEmpty())
				{ 
					//res+=L"--"+full_path+L"--";
					char *file=W2A(full_path.AllocSysString());
					if(NULL!=file)
					{
						char buff[128]={0};
						_itoa_s(dir_index++,buff,128,10);
						root[buff]=file;
					}
				}
			}
			if( cff.GetFileName().Find(L".jpg")>0||
				cff.GetFileName().Find(L".gif")>0||
				cff.GetFileName().Find(L".png")>0||
				cff.GetFileName().Find(L".bmp")>0
				)
			{
				/*		  CMSBOX("image");
				return NULL;*/
				//CMSBOXW(cff.GetFilePath());
				char l_buff[128]={0};
				_itoa_s(image_index++,l_buff,128,10);
				images[l_buff]=W2A(cff.GetFilePath());
			}
		}
		cff.Close();
	}

	if(images.size()>=1)
	{
		root["images"]=images;
	}
	retStr=fw.write(root);
	//CMSBOXW(res);
	if(retStr.length()>0)
	{
		return SysAllocString(A2W(retStr.c_str()));
	}
	return CString("1").AllocSysString();
}
コード例 #30
0
/*******************  start of server  ****************************/
void regist_change(void *arg) //0
{	
	Value root;
	Reader reader;
	struct user * puser = (struct user*)arg;
	pthread_mutex_lock(&(puser->msg_lock));
	string data = puser->data;
	pthread_mutex_unlock(&(puser->msg_lock));
	if(reader.parse(data,root))
	{
		Value ret;
		FastWriter writer;
		int typecode = root["typecode"].asInt();
		string name = root["username"].asString();
		string paswd = root["password"].asString();
		string email = root["email"].asString();
		int age = root["age"].asInt();
		int facetype = root["facetype"].asInt();
		int sex = root["sex"].asInt();
		int headpicID = root["headpicID"].asInt();
		
		struct USER *pusrinfor;
		pusrinfor = new USER();
		//pusrinfor = (struct USER *)malloc(sizeof(struct USER));
		pusrinfor->username = name;
		pusrinfor->passwd = paswd;
		pusrinfor->mail = email;
		pusrinfor->sex = sex;
		pusrinfor->age = age;
		pusrinfor->facetype = facetype;
		pusrinfor->portrait = headpicID;

		if((name == "")||(paswd == ""))		//data is wrong
		{
			cout<<"in login,data is wrong"<<endl;
			ret["typecode"] = 11;
		}
		else if(typecode == 1)		//regist
		{	
			int flag = registration(pusrinfor);
			if(flag == 1)
				ret["typecode"] = 10;
			else 
				ret["typecode"] = 11;
		}
			
		else						//change information
		 {
		 	int flag;
			//cout << "ccccccc" << endl;
			flag = changeinfo(pusrinfor);
		 	if(flag == 1)
				ret["typecode"] = 50;
			else
				ret["typecode"] = 51;
		}
		delete pusrinfor;
		string strdata = writer.write(ret);
		
		pthread_mutex_lock(&(puser->msg_lock));
		puser->msg.push_back(strdata);			//add data to send vector
		pthread_mutex_unlock(&(puser->msg_lock));
	}
}