示例#1
0
	bool OnLoad(const CString& sArgs, CString& sMessage) override {
		CString sReasonArg;

		// Load AwayWait
		CString sFirstArg = sArgs.Token(0);
		if (sFirstArg.Equals("-notimer")) {
			SetAwayWait(0);
			sReasonArg = sArgs.Token(1, true);
		} else if (sFirstArg.Equals("-timer")) {
			SetAwayWait(sArgs.Token(1).ToUInt());
			sReasonArg = sArgs.Token(2, true);
		} else {
			CString sAwayWait = GetNV("awaywait");
			if (!sAwayWait.empty())
				SetAwayWait(sAwayWait.ToUInt(), false);
			sReasonArg = sArgs;
		}

		// Load Reason
		if (!sReasonArg.empty()) {
			SetReason(sReasonArg);
		} else {
			CString sSavedReason = GetNV("reason");
			if (!sSavedReason.empty())
				SetReason(sSavedReason, false);
		}

		// Set away on load, required if loaded via webadmin
		if (GetNetwork()->IsIRCConnected() && !GetNetwork()->IsUserAttached())
			SetAway(false);

		return true;
	}
示例#2
0
//CALLBACK!
void
Jabber::Authorized()
{
	SetAway(false);
	
	fPerc +=0.3333;
	fAuth=true;
	Progress("Jabber Login", "Jabber: Authorized", fPerc);
	LOG(kProtocolName, liDebug, "Jabber:Login %f - Authorized",fPerc) ;
	CheckLoginStatus();
	
	JabberHandler::Authorized();
}
bool NiftyKbFunctions::SetGlobalAway(bool isAway, char* msg)
{
	uint64* servers;
	uint64 handle;
	int i;

	if(CheckAndLog(ts3Functions.getServerConnectionHandlerList(&servers), "Error retrieving list of servers"))
		return false;

	handle = servers[0];
	for(i = 1; handle != (uint64)NULL; i++)
	{
		SetAway(handle, isAway, msg);
		handle = servers[i];
	}

	ts3Functions.freeMemory(servers);
	return true;
}
示例#4
0
bool CNest::WriteToHardware(const char *pdata, const unsigned char length)
{
	if (m_UserName.size() == 0)
		return false;
	if (m_Password.size() == 0)
		return false;

	const tRBUF *pCmd = reinterpret_cast<const tRBUF *>(pdata);
	if (pCmd->LIGHTING2.packettype != pTypeLighting2)
		return false; //later add RGB support, if someone can provide access

	int node_id = pCmd->LIGHTING2.id4;

	bool bIsOn = (pCmd->LIGHTING2.cmnd == light2_sOn);

	if (node_id % 3 == 0)
	{
		//Away
		return SetAway(node_id, bIsOn);
	}

	return false;
}
示例#5
0
bool CAnnaThermostat::WriteToHardware(const char *pdata, const unsigned char length)
{
	if (m_UserName.size() == 0)
		return false;
	if (m_Password.size() == 0)
		return false;

	tRBUF *pCmd = (tRBUF *)pdata;
	if (pCmd->LIGHTING2.packettype != pTypeLighting2)
		return false; //later add RGB support, if someone can provide access

	int node_id = pCmd->LIGHTING2.id4;

	bool bIsOn = (pCmd->LIGHTING2.cmnd == light2_sOn);

	if (node_id == 3)
	{
		//Away
		return SetAway(bIsOn);
	}

	return false;
}
示例#6
0
status_t
Jabber::Process( BMessage * msg )
{
	switch ( msg->what )
	{
		case IM::MESSAGE:
		{
			int32 im_what = 0;
			
			msg->FindInt32("im_what", &im_what );
						
			switch ( im_what )
			{
				case IM::SET_STATUS:
				{
					const char *status = msg->FindString("status");
					LOG(kProtocolName, liMedium, "Set status to %s", status);
					
					if (strcmp(status, OFFLINE_TEXT) == 0) 
					{
							
						SetStatus(S_OFFLINE,OFFLINE_TEXT); //do the log-out?
					} 
					else 
					if (strcmp(status, AWAY_TEXT) == 0) 
					{
						if(IsAuthorized()){
						
						 //const char *away_msg;	
						 BString away_msg;					 
						 if(msg->FindString("away_msg",&away_msg) == B_OK)
						 {
						 	// quick and dirty way to use advanced away status:
						 	// add 'DND: ' for Do not Disturb
						 	// or  'XA: ' for Extended Away
						 	
						 	if(away_msg.Compare("DND: ",4) == 0)
						 		SetStatus(S_DND,away_msg); 
						 	else
						 	if(away_msg.Compare("XA: ",4) == 0)
						 		SetStatus(S_XA,away_msg); 
						 	else	
						 		SetStatus(S_AWAY,away_msg); 
						 }
						 	 else
						 		 SetStatus(S_AWAY,AWAY_TEXT); 
						 
						 			
						 SetAway(true);
						} 
					} 
					else 
					if (strcmp(status, ONLINE_TEXT) == 0) 
					{
							if(!IsAuthorized())
							{
								if(fUsername == "")
									Error("Empty Username!",NULL);
								if(fServer == "")
									Error("Empty Server!",NULL);
								if(fPassword == "")
									Error("Empty Password!",NULL);
								
								Progress("Jabber Login", "Jabber: Connecting..", 0.0);
										
							}
							
							SetStatus(S_ONLINE,ONLINE_TEXT); //do the login!
							if(IsAuthorized()) SetAway(false); 
					} 
					else
					{
						Error("Invalid",NULL);
						LOG(kProtocolName, liHigh, "Invalid status when setting status: '%s'", status);
					}
				}	break;
				
				case IM::SEND_MESSAGE:
				{
						const char * buddy=msg->FindString("id");
						const char * sms=msg->FindString("message");
						JabberMessage jm;
						jm.SetTo(buddy);
						jm.SetFrom(GetJid());
						jm.SetBody(sms);
						TimeStamp(jm);
						
						//not the right place.. see Jabber::Message
						JabberContact *contact=getContact(buddy);
						
						//tmp: new mess id!
						BString messid("imkit_");
						messid << idsms;
						idsms++;
						
						if(contact)
							jm.SetID(messid);
												
						SendMessage(jm);
						
						MessageSent(buddy,sms);
				} 
				break;
				case IM::REGISTER_CONTACTS:
					
					{
					
					//debugger("REGISTER");
					type_code garbage;
					int32 count = 0;
					msg->GetInfo("id", &garbage, &count);
					
										
					if (count > 0 ) {
						
						for ( int i=0; msg->FindString("id",i); i++ )
						{
							const char * id = msg->FindString("id",i);
							JabberContact* contact=getContact(id);
							if(contact)
								  BuddyStatusChanged(contact);
							else
							{
							 
								//Are we on-line?
								// send auth req?
								if(fFullLogged)
								{ 			
									AddContact(id,id,"");
									BuddyStatusChanged(id,OFFLINE_TEXT);
								}
								
								else
								{
								 // we add to a temp list.
								 // when logged in we will register the new buddy..
									 fLaterBuddyList->push_back(BString(id));
								}							 
							} 
						};
						
					} 
					else 
						return B_ERROR;
					} 	
					break;
				case IM::UNREGISTER_CONTACTS:
				
				{
						
					
						const char * buddy=NULL;
						
						for ( int i=0; msg->FindString("id", i, &buddy) == B_OK; i++ )
						{
							LOG(kProtocolName, liDebug, "Unregister Contact: '%s'", buddy);
							
							if(!fFullLogged)
							BuddyStatusChanged(buddy,OFFLINE_TEXT);
							else
							{
								LOG(kProtocolName, liDebug, "Unregister Contact DOING IT");
							 	JabberContact* contact=getContact(buddy);
							 	if(contact)
									RemoveContact(contact);
							}
						}
				} 
					
					break;
				case IM::USER_STARTED_TYPING: 
				{
						const char * id=NULL;
						
						if( msg->FindString("id", &id) == B_OK )
						{
						 JabberContact* contact=getContact(id);
						 if(contact)
							StartComposingMessage(contact);
						}
				} 
				break;
				case IM::USER_STOPPED_TYPING: 
				{
						const char * id=NULL;
						
						if( msg->FindString("id", &id) == B_OK )
						{
						 JabberContact* contact=getContact(id);
						 if(contact && (contact->GetLastMessageID().ICompare("")!=0)){
							StopComposingMessage(contact);
							contact->SetLastMessageID("");
							
							}
						}
				} 
				break;
				
				case IM::GET_CONTACT_INFO:
					//debugger("Get Contact Info! ;)");
					SendContactInfo(msg->FindString("id"));
				break;
								
				case IM::SEND_AUTH_ACK:
				{
					if(!IsAuthorized())
						return B_ERROR;
					
					const char * id = msg->FindString("id");
					int32 button = msg->FindInt32("which");
					
					if (button == 0) {
						
						//Authorization granted
						AcceptSubscription(id);
						BMessage im_msg(IM::MESSAGE);
						im_msg.AddInt32("im_what", IM::CONTACT_AUTHORIZED);
						im_msg.AddString("protocol", kProtocolName);
						im_msg.AddString("id", id);
						im_msg.AddString("message", "");
						fServerMsgr.SendMessage(&im_msg);
						
						//now we want to see you! ;)
						AddContact(id,id,"");
														
					} 
					else 
					{
						//Authorization rejected
						Error("Authorization rejected!",id);
					}
						
					
				}
				break;
				default:
					// we don't handle this im_what code
					msg->PrintToStream();	
					return B_ERROR;
			}
		}	break;
		
		default:
			// we don't handle this what code
			return B_ERROR;
	}
	
	return B_OK;
}
示例#7
0
	void OnIRCConnected() override {
		if (GetNetwork()->IsUserAttached())
			SetBack();
		else
			SetAway(false);
	}
示例#8
0
	void OnClientDisconnect() override {
		/* There might still be other clients */
		if (!GetNetwork()->IsUserAttached())
			SetAway();
	}
示例#9
0
	virtual void OnClientDisconnect() {
		/* There might still be other clients */
		if (!m_pUser->IsUserAttached())
			SetAway();
	}
示例#10
0
	virtual void OnIRCConnected() {
		if (m_pUser->IsUserAttached())
			SetBack();
		else
			SetAway(false);
	}
示例#11
0
 void OnClientDisconnect() override {
     /* There might still be other clients */
     if (!MinClientsConnected()) SetAway();
 }
示例#12
0
 void OnIRCConnected() override {
     if (MinClientsConnected())
         SetBack();
     else
         SetAway(false);
 }