Esempio n. 1
0
CCode 
StoreCommandAUTHCOOKIE(StoreClient *client, char *user, char *token, int nouser)
{
	CCode ccode;

	if (StoreAgent.installMode)
		// don't allow cookie logins in installation mode. FIXME: better error message?
		return ConnWriteStr(client->conn, MSG3242BADAUTH);

	if (0 != MsgAuthFindUser(user)) {
		Log(LOG_INFO, "Couldn't find user object for %s\r\n", user);
		
		XplDelay(2000);
		return ConnWriteStr(client->conn, MSG3242BADAUTH);
	}

	MsgSQLStatement stmt;
	MsgSQLStatement *find = NULL;
	int result;
	
	MsgSQLHandle *db = OpenCookieDB(client);
	
	if (MsgSQLBeginTransaction(db)) return -2;
	
	memset(&stmt, 0, sizeof(MsgSQLStatement));
	find = MsgSQLPrepare(db, "SELECT id FROM cookies WHERE user = ? AND cookie = ? AND expiration > ?;", &stmt);
	if (find == NULL) goto abort;
	
	MsgSQLBindString(find, 1, user, FALSE);
	MsgSQLBindString(find, 2, token, FALSE);
	MsgSQLBindInt64(find, 3, time(NULL));
	
	result = MsgSQLResults(db, find);
	if (result < 0) goto abort;
	
	MsgSQLFinalize(&stmt);
	if (MsgSQLCommitTransaction(db))
		goto abort;

	MsgSQLClose(db);

	if (result == 0) {
		XplDelay(2000);        
		ccode = ConnWriteStr(client->conn, MSG3242BADAUTH);
	} else {
		ccode = SelectUser(client, user, NULL, nouser);
	}

	return ccode;

abort:
	MsgSQLFinalize(&stmt);
	MsgSQLAbortTransaction(db);
	if (db) MsgSQLClose(db);
	return ConnWriteStr(client->conn, MSG5004INTERNALERR);
}
Esempio n. 2
0
/***************************************************************************************************
*FunctionName: activityResume
*Description: 界面恢复显示时要做的事
*Input: 
*Output: 
*Return: 
*Author: xsx
*Date: 2016年12月21日09:01:58
***************************************************************************************************/
static void activityResume(void)
{
	/*读取所有操作人*/
	ReadUserData(S_UserPageBuffer->user);
	
	S_UserPageBuffer->pageindex = 1;
	S_UserPageBuffer->selectindex = 0;
	
	ShowList();
	SelectUser(S_UserPageBuffer->selectindex);
		
	AddNumOfSongToList(9, 0);
	
	SelectPage(84);
}
Esempio n. 3
0
/***************************************************************************************************
*FunctionName: activityStart
*Description: 显示主界面
*Input: 
*Output: 
*Return: 
*Author: xsx
*Date: 2016年12月21日09:00:32
***************************************************************************************************/
static void activityStart(void)
{
	/*获取当前测试的数据指针*/
	S_UserPageBuffer->currenttestdata = GetCurrentTestItem();
	S_UserPageBuffer->currenttestdata->statues = status_user;
	
	/*读取所有操作人*/
	ReadUserData(S_UserPageBuffer->user);
	
	S_UserPageBuffer->pageindex = 1;
	S_UserPageBuffer->selectindex = 0;
	
	ShowList();
	SelectUser(S_UserPageBuffer->selectindex);
		
	AddNumOfSongToList(9, 0);
	
	SelectPage(84);
}
Esempio n. 4
0
/***************************************************************************************************
*FunctionName: activityInput
*Description: 界面输入
*Input: 
*Output: 
*Return: 
*Author: xsx
*Date: 2016年12月21日09:00:59
***************************************************************************************************/
static void activityInput(unsigned char *pbuf , unsigned short len)
{
	S_UserPageBuffer->lcdinput[0] = pbuf[4];
	S_UserPageBuffer->lcdinput[0] = (S_UserPageBuffer->lcdinput[0]<<8) + pbuf[5];
		
	/*返回*/
	if(S_UserPageBuffer->lcdinput[0] == 0x1200)
	{
		DeleteCurrentTest();
			
		backToActivity(lunchActivityName);
	}
		
	/*上翻也*/
	else if(S_UserPageBuffer->lcdinput[0] == 0x1203)
	{			
		if(S_UserPageBuffer->pageindex > 1)
		{
			S_UserPageBuffer->pageindex--;
						
			S_UserPageBuffer->selectindex = 0;
						
			ShowList();
			SelectUser(S_UserPageBuffer->selectindex);
		}
	}
	/*下翻页*/
	else if(S_UserPageBuffer->lcdinput[0] == 0x1204)
	{			
		if(S_UserPageBuffer->pageindex < (MaxUserNum / MaxPageShowNum))
		{
			S_UserPageBuffer->tempUser = &S_UserPageBuffer->user[(S_UserPageBuffer->pageindex)*MaxPageShowNum];
			
			if(S_UserPageBuffer->tempUser->crc == CalModbusCRC16Fun1(S_UserPageBuffer->tempUser, sizeof(User_Type)-2))
			{
				S_UserPageBuffer->pageindex++;
						
				S_UserPageBuffer->selectindex = 0;
						
				ShowList();
				SelectUser(S_UserPageBuffer->selectindex);
			}
		}
	}
	/*确定*/
	else if(S_UserPageBuffer->lcdinput[0] == 0x1201)
	{
		if(S_UserPageBuffer->tempUser2 != NULL)
		{
			//如果是排队测试,则保存操作人到排队测试共用操作人
			if(S_UserPageBuffer->currenttestdata->testlocation > 0)
				SetPaiduiUser(S_UserPageBuffer->tempUser2);
				
			/*以当前选择的操作人作为本次测试数据的操作人*/
			memcpy(&(S_UserPageBuffer->currenttestdata->testdata.user), S_UserPageBuffer->tempUser2, sizeof(User_Type));
			
			startActivity(createSampleActivity, NULL);
		}
		else
		{
			AddNumOfSongToList(9, 0);
			SendKeyCode(1);
		}
	}
	/*选择操作人*/
	else if((S_UserPageBuffer->lcdinput[0] >= 0x1205)&&(S_UserPageBuffer->lcdinput[0] <= 0x1209))
	{			
		S_UserPageBuffer->selectindex = S_UserPageBuffer->lcdinput[0] - 0x1205+1;
		SelectUser(S_UserPageBuffer->selectindex);
	}
	//编辑操作人
	if(S_UserPageBuffer->lcdinput[0] == 0x120a)
	{
		startActivity(createUserManagerActivity, NULL);
	}
}
/**
 * @ingroup KSipServer
 * @brief SIP Call Pick up 통화 요청 수신 이벤트 핸들러
 * @param	pszCallId	SIP Call-ID
 * @param pszFrom		SIP From 사용자 아이디
 * @param pszTo			SIP To 사용자 아이디
 * @param pclsRtp		RTP 정보 저장 객체
 */
void CSipServer::PickUp( const char * pszCallId, const char * pszFrom, const char * pszTo, CSipCallRtp * pclsRtp )
{
	CXmlUser	xmlFrom;
	USER_ID_LIST	clsUserIdList;
	bool bCallPickup = false;

	CLog::Print( LOG_DEBUG, "EventIncomingCall(%s,%s,%s)  CallPickup", pszCallId, pszFrom, pszTo );

	if( SelectUser( pszFrom, xmlFrom ) && gclsUserMap.SelectGroup( xmlFrom.m_strGroupId.c_str(), clsUserIdList ) )
	{
		USER_ID_LIST::iterator	itUIL;
		std::string strOldCallId;

		for( itUIL = clsUserIdList.begin(); itUIL != clsUserIdList.end(); ++itUIL )
		{
			if( gclsCallMap.SelectToRing( itUIL->c_str(), strOldCallId ) == false ) continue;

			CCallInfo clsOldCallInfo;

			if( gclsCallMap.Select( strOldCallId.c_str(), clsOldCallInfo ) && gclsCallMap.Insert( pszCallId, clsOldCallInfo ) )
			{
				// #2 통화를 종료시킨다.
				gclsCallMap.DeleteOne( strOldCallId.c_str() );
				gclsUserAgent.StopCall( strOldCallId.c_str() );

				CSipCallRtp clsRemoteRtp;

				if( gclsUserAgent.GetRemoteCallRtp( clsOldCallInfo.m_strPeerCallId.c_str(), &clsRemoteRtp ) )
				{
					if( pclsRtp )
					{
						if( clsOldCallInfo.m_iPeerRtpPort > 0 )
						{
							pclsRtp->m_iPort = clsOldCallInfo.m_iPeerRtpPort;
							pclsRtp->m_strIp = gclsSetup.m_strLocalIp;
						}

						pclsRtp->m_iCodec = clsRemoteRtp.m_iCodec;
					}

					// #1 통화 연결
					if( gclsUserAgent.AcceptCall( clsOldCallInfo.m_strPeerCallId.c_str(), pclsRtp ) )
					{
						CCallInfo clsPeerCallInfo;

						if( gclsCallMap.Select( clsOldCallInfo.m_strPeerCallId.c_str(), clsPeerCallInfo ) )
						{
							gclsCallMap.Update( clsOldCallInfo.m_strPeerCallId.c_str(), pszCallId );

							if( pclsRtp )
							{
								if( clsOldCallInfo.m_iPeerRtpPort > 0 )
								{
									pclsRtp->m_iPort = clsPeerCallInfo.m_iPeerRtpPort;
								}
								else
								{
									pclsRtp = &clsRemoteRtp;
								}
							}

							// #3 통화 연결
							gclsUserAgent.AcceptCall( pszCallId, pclsRtp );
							bCallPickup = true;
						}
						
						if( bCallPickup == false )
						{
							gclsUserAgent.StopCall( clsOldCallInfo.m_strPeerCallId.c_str() );	
						}
					}
				}
			}

			break;
		}
	}
	
	if( bCallPickup == false )
	{
		CLog::Print( LOG_DEBUG, "EventIncomingCall CallPickup from(%s) is not found", pszFrom );
		StopCall( pszCallId, SIP_NOT_FOUND );
	}
}