Example #1
0
	virtual void OnClientDisconnect() {
		CDevice *pDevice = DeviceForClient(*m_pClient);
		if (pDevice) {
			pDevice->SetInNegotiation(false);
			pDevice->RemoveClient(*m_pClient);
		}
	}
Example #2
0
	virtual EModRet HandleUserRaw(CClient* pClient, CString& sLine) {
		if (sLine.Token(0).Equals(kPLVCommand)) {
			CString sCommand = sLine.Token(1);

			if (sCommand.Equals("BACKGROUND")) {
				m_pClient->SetAway(true);
			} else if (sCommand.Equals("FOREGROUND")) {
				m_pClient->SetAway(false);
			} else if (sCommand.Equals("IDENTIFY")) {
				CDevice *pDevice = DeviceForClient(*pClient);
				if (pDevice) {
					pDevice->RemoveClient(*pClient);
				}

				CString sToken = sLine.Token(2);
				CString sVersion = sLine.Token(3);

				CDevice& device = DeviceWithToken(sToken);

				if (device.InNegotiation() == false && device.GetVersion().Equals(sVersion) == false) {
					pClient->PutClient("PALAVER REQ *");
					device.SetInNegotiation(true);
				}

				device.AddClient(*pClient);

				if (m_pNetwork) {
					device.AddNetwork(*m_pNetwork);
				}
			} else if (sCommand.Equals("BEGIN")) {
				CString sToken = sLine.Token(2);
				CString sVersion = sLine.Token(3);
				CDevice& device = DeviceWithToken(sToken);

				device.ResetDevice();
				device.SetInNegotiation(true);
				device.SetVersion(sVersion);

				device.AddClient(*pClient);
			} else if (sCommand.Equals("END")) {
				CDevice *pDevice = DeviceForClient(*pClient);

				if (pDevice) {
					pDevice->SetInNegotiation(false);
				}
			} else if (sCommand.Equals("SET")) {
				CString sKey = sLine.Token(2);
				CString sValue = sLine.Token(3, true);

				CDevice *pDevice = DeviceForClient(*pClient);

				if (pDevice) {
					if (sKey.Equals("VERSION")) {
						pDevice->SetVersion(sValue);
					} else if (sKey.Equals(kPLVPushEndpointKey)) {
						pDevice->SetPushEndpoint(sValue);
					}
				}
			} else if (sCommand.Equals("ADD")) {
				CString sKey = sLine.Token(2);
				CString sValue = sLine.Token(3, true);

				CDevice *pDevice = DeviceForClient(*pClient);

				if (pDevice) {
					if (sKey.Equals(kPLVIgnoreKeywordKey)) {
						pDevice->AddIgnoreKeyword(sValue);
					} else if (sKey.Equals(kPLVIgnoreChannelKey)) {
						pDevice->AddIgnoreChannel(sValue);
					} else if (sKey.Equals(kPLVIgnoreNickKey)) {
						pDevice->AddIgnoreNick(sValue);
					} else if (sKey.Equals(kPLVMentionKeywordKey)) {
						pDevice->AddMentionKeyword(sValue);
					} else if (sKey.Equals(kPLVMentionChannelKey)) {
						pDevice->AddMentionChannel(sValue);
					} else if (sKey.Equals(kPLVMentionNickKey)) {
						pDevice->AddMentionNick(sValue);
					}
				}
			}

			return HALT;
		}

		return CONTINUE;
	}