Ejemplo n.º 1
0
/**
	popup menu
 */
void MainWindows::slotPopupMenu(  const QPoint & point )
{
	currentPopupMenuItem = treeWidget->itemAt ( point );
	// if object is dead
	if (!QTreeWidgetItemList.contains(currentPopupMenuItem)) return;

	if( currentPopupMenuItem )
	{
		// create popup menu
		menuPopup->clear();

		if (currentPopupMenuItem==item_server) // if a server item
		{
			menuPopup->addAction ( tr( "Properties"),this,SLOT(InfoServer() ) );
			QAction * action=menuPopup->addAction ( tr( "Send out message to all users"),this,SLOT(slotSendMessageAllUsers() ) );
			action->setEnabled(permitSendMsg);
			menuPopup->exec( QCursor::pos() );
			return;
		}
		if (currentPopupMenuItem->parent()==item_server) // if a machine item
		{
			machine * myItem=dynamic_cast<machine *>(currentPopupMenuItem);
			if (!myItem) return;
			menuPopup->addAction ( tr( "Properties"),this,SLOT(InfoMachine() ) );
			QAction * action=menuPopup->addAction ( tr( "Send out message to")+ " " + myItem->machine_name,this,SLOT(slotSendMessage() ) );
			action->setEnabled(permitSendMsg); // if client can send popup messages
			menuPopup->exec( QCursor::pos() );
			return;
		}
		if (currentPopupMenuItem->parent()->parent()==item_server) // if an user item
		{
			user * myItem=dynamic_cast<user *>(currentPopupMenuItem);
			if (!myItem) return;
			menuPopup->addAction ( tr( "Properties"),this,SLOT(InfoUser() ) );
			QAction * action=menuPopup->addAction ( tr( "Disconnect user")+ " " + myItem->username,this,SLOT(slotDisconnectUser() ) );
			action->setEnabled(permitDisconnectUser); //  if client can disconnect an user
			menuPopup->exec( QCursor::pos() );
			return;
		}
		// it's a locked file or share
		menuPopup->addAction ( tr( "Properties"),this,SLOT(InfoService() ) );
		menuPopup->exec( QCursor::pos() );
	}
}
Ejemplo n.º 2
0
LRESULT CInviteChatDlg::OnNetEvent(WPARAM w,LPARAM l)
{
	NLT_Container *pItem = (NLT_Container *)w;
	ASSERT(pItem!=NULL);
	
	UnBlock();
	switch(pItem->EventType)
	{
	case NLT_EDetails:
		{
			IUser    *pUser    = NULL;
			HRESULT hr = AutoUnMarchaling(pItem,(LPUNKNOWN*)&pUser);
			
			if(SUCCEEDED(hr))
			{
				theNet2.LockTranslator();
				theNet2.RemoveFromTranslator(Handle);
				try
				{
					CUser InfoUser(pUser);
					m_User = InfoUser;

					CString strNickText;
					strNickText.Format(GetString(IDS_INVITE_CHAT_NICK_NAME),m_User.GetShowName());
					m_Nick.SetWindowText(strNickText);
					
					UpdateData(FALSE);
				}
				catch(...)
				{
					ASSERT(FALSE);
				}
				theNet2.UnlockTranslator();
				pUser->Release();
			}
		}
		break;
	case NLT_EChatCreate:
		{
			IChat *pChat	=	NULL;
			HRESULT hr = AutoUnMarchaling(pItem,(LPUNKNOWN*)&pChat);
			if(hr==S_OK)
			{
				// Step 1. Add new Chat to ChatsCollections [8/9/2002]
				pMessenger->AddNewChat(pChat,SC_INACTIVE);
				// Step 2. Connect to Chat [9/7/2002]
				CChat Chat(pChat);
				pMessenger->SetChatStatus(Chat.GetId(),SC_ACTIVE,CMainDlg::HCI_OPEN_CHAT_WINDOW);
				// Step 2. Free Interface [8/9/2002]
				pChat->Release();
			}
			// Step 3. Close the Window
			KillWindow();
		}
		break;
	case NLT_ECommandOK:
		theNet2.LockTranslator();
		theNet2.RemoveFromTranslator(Handle);
		theNet2.UnlockTranslator();
		KillWindow();
		break;
	case NLT_ECommandError:
		theNet2.LockTranslator();
		theNet2.RemoveFromTranslator(Handle);
		theNet2.UnlockTranslator();
		if(pItem->Long1==etSERVER)
		{
			switch(pItem->Long2)
			{
			case ERR_UNABLE_CREATE_CONN:
				_SHOW_IBN_ERROR_DLG_OK(IDS_SERVICENOTAVAILABLE);
				break;
			}
		}
		MessageBox(GetString(IDS_INVITECHAT_ERROR),GetString(IDS_ERROR_TITLE),MB_OK|MB_ICONSTOP);
		break;
	}
	
	delete pItem;
    return 0;
}
Ejemplo n.º 3
0
LRESULT CAddUserRequest::OnNetEvent(WPARAM w,LPARAM l)
{
	NLT_Container *pItem = (NLT_Container *)w;
	ASSERT(pItem!=NULL);
	
	
	UnBlock();
	switch(pItem->EventType)
	{
	case NLT_EDetails:
		{
			IUser    *pUser    = NULL;
			HRESULT hr = AutoUnMarchaling(pItem,(LPUNKNOWN*)&pUser);
			
			if(SUCCEEDED(hr))
			{
				theNet2.LockTranslator();
				theNet2.RemoveFromTranslator(Handle);
				try
				{
					CUser InfoUser(pUser);
					m_User = InfoUser;
					m_Nick.SetText(m_User.GetShowName());

					UpdateData(FALSE);
				}
				catch(...)
				{
					ASSERT(FALSE);
				}
				theNet2.UnlockTranslator();
				pUser->Release();
			}
		}
		break;
	case NLT_ECommandOK:
		theNet2.LockTranslator();
		theNet2.RemoveFromTranslator(Handle);
		theNet2.UnlockTranslator();
		if(m_bAddUserCommand&&!pMessenger->CheckUserInContactList(m_User))
		{
			//GetDlgItem(IDOK)->ShowWindow(SW_HIDE);
			//GetDlgItem(ID_DANY)->ShowWindow(SW_HIDE);
			m_Accept.ShowWindow(SW_HIDE);
			m_Deny.ShowWindow(SW_HIDE);
			m_AddToContact.ShowWindow(SW_SHOWNORMAL);
			//GetDlgItem(ID_AUTHORIZATION_REQUEST)->ShowWindow(SW_SHOWNORMAL);
		}
		else
			KillWindow();
		break;
	case NLT_ECommandError:
		theNet2.LockTranslator();
		theNet2.RemoveFromTranslator(Handle);
		theNet2.UnlockTranslator();
		if(pItem->Long1==etSERVER)
		{
			switch(pItem->Long2)
			{
			case ERR_UNABLE_CREATE_CONN:
				_SHOW_IBN_ERROR_DLG_OK(IDS_SERVICENOTAVAILABLE);
				break;
			}
		}
		MessageBox(GetString(IDS_ADD_USER_ERROR),GetString(IDS_ERROR_TITLE),MB_OK|MB_ICONSTOP);
		break;
	}
	
	delete pItem;
    return 0;
}