Пример #1
0
	DocWindowFrame::DocWindowFrame(
		App&					app,
		xcb_connection_t*		conn,
		xcb_window_t			parent,
		xcb_screen_t*			screen,
		ClientWindow&			client)
		: WindowFrame(app, conn, client)
		, mFrameWindow(
				conn, screen, parent,
				XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_BUTTON_PRESS,
				100 + client.getX() - 20, 100 + client.getY() - 20,
				client.getWidth() + kWindowWidthDelta,
				client.getHeight() + kWindowHeightDelta)
	{
		mWindowLabel = new Label(app, screen, mFrameWindow, app.getBlackPen(),
				&app.getSystemFont(), Label::kHAlignLeft,
				app.getColor(kColorGray), 5, 2, 100, 18, L"");

		mFrameParentWindow = screen->root;

		mGc = xcb_generate_id(app);
		uint32_t			mask = XCB_GC_FOREGROUND;
		uint32_t			values[] = { app.getColor(kColorGray) };
		xcb_create_gc(app, mGc, mFrameWindow, mask, values);

		app.addWindowHandler(mFrameWindow, this);

		// Reparent last to make the client window topmost
		client.reparent(&mFrameWindow, kWindowPosLeft, kWindowPosTop);
		setTitle(L"Test title");
	}
Пример #2
0
int32
ClientWindow::ExecPipe (void *arg)
{
	BMessage *msg (reinterpret_cast<BMessage *>(arg));
	const char *exec;
	ClientWindow *client;
	
	msg->FindString ("exec", &exec);
	msg->FindPointer ("client", reinterpret_cast<void **>(&client));
	
	delete msg;
	
	FILE *fp = popen(exec, "r");

	char read[768]; // should be long enough for any line...
		
	while (fgets(read, 768, fp))
	{
		read[strlen(read)-1] = '\0'; // strip newline		
		
		BMessage msg (M_SUBMIT_RAW);
		msg.AddBool ("lines", 1);
		msg.AddString ("data", read);			
		client->PostMessage (&msg);
	}
		
	pclose(fp);
	
	return 0;

}
Пример #3
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    ClientWindow w;
    w.show();


    return a.exec();
}
Пример #4
0
int32
ClientWindow::DNSLookup (void *arg)
{
	BMessage *msg (reinterpret_cast<BMessage *>(arg));
	const char *lookup;
	ClientWindow *client;
	
	msg->FindString ("lookup", &lookup);
	msg->FindPointer ("client", reinterpret_cast<void **>(&client));
	
	delete msg;
	
	BString resolve (lookup),
			output ("[x] ");
	
	if (isalpha(resolve[0]))
	{
		hostent *hp = gethostbyname (resolve.String());
				
		if(hp)
		{
			// ip address is in hp->h_addr_list[0];
			char addr_buf[16];
					
			in_addr *addr = (in_addr *)hp->h_addr_list[0];
			strcpy(addr_buf, inet_ntoa(*addr));

			output << "Resolved " << resolve.String() << " to " << addr_buf;
		}
		else
		{
			output << "Unable to resolve " << resolve.String();
		}
	}
	else
	{
		ulong addr = inet_addr (resolve.String());
				
		hostent *hp = gethostbyaddr ((const char *)&addr, 4, AF_INET);
		if(hp)
		{
			output << "Resolved " << resolve.String() << " to " << hp->h_name;
		}
		else
		{
			output << "Unable to resolve " << resolve.String();
		}
	}
	output << "\n";
	
	BMessage dnsMsg (M_DISPLAY);
	client->PackDisplay (&dnsMsg, output.String(), &(client->whoisColor));
	client->PostMessage (&dnsMsg);	
	
	return 0;

}
Пример #5
0
void MainPresenter::createClientWindow(const int index)
{
    const int id = (clients.at(index))->getID();

    ClientWindow *window = new ClientWindow();
    ClientPresenter *presenter = new ClientPresenter(id);
    presenter->setView(window);
    window->choosePresenter(presenter);

    window->exec();
}
Пример #6
0
void
NotifyList::MessageReceived (BMessage *msg)
{
  switch (msg->what)
  {
    case M_NOTIFYLIST_RESIZE:
      {
        ClientWindow *cWin (vision_app->pClientWin());
        cWin->DispatchMessage (msg, cWin->pCwDock());
        break;
      }
    
    case M_THEME_FOREGROUND_CHANGE:
      {
        int16 which (msg->FindInt16 ("which"));
        bool refresh (false);
        switch (which)
        {
          case C_NOTIFYLIST_BACKGROUND:
            fActiveTheme->ReadLock();
            SetViewColor (fActiveTheme->ForegroundAt (C_NOTIFYLIST_BACKGROUND));
            fActiveTheme->ReadUnlock();
            refresh = true;
            break;
          
          case C_NOTIFY_ON:
          case C_NOTIFY_OFF:
          case C_NOTIFYLIST_SELECTION:
            refresh = true;
            break;
        }
        if (refresh)
          Invalidate();
      }
      break;

    case M_THEME_FONT_CHANGE:
      {
        int16 which (msg->FindInt16 ("which"));
        if (which == F_WINLIST)
        {
          fActiveTheme->ReadLock();
          SetFont (&fActiveTheme->FontAt (F_WINLIST));
          fActiveTheme->ReadUnlock();
          Invalidate();
        }
      }
      break;
      
    default:
      BListView::MessageReceived (msg);
  }
}
Пример #7
0
	void
	RootWindow::onMapRequestEvent(
		xcb_map_request_event_t*	event)
	{
		printf("map_request on root; window=0x%08X\n", event->window);

		xcb_connection_t*		conn = mWindow.getConnection();
		ClientWindow*			client = new ClientWindow(mApp, conn, mScreen, mWindow.getWindow(), event->window);
		client->show();


		//xcb_map_window(conn, event->window);
		xcb_flush(conn);
	}
Пример #8
0
int main(int argc, char** argv) {

  int mainResult = 0;

  Globals::initServices("localhost",1234);

  try {
    Globals::transport->open();

    try{

        CallResult result;

        Globals::networkService ->ping(result);
        if(result.resultCode == ResultCode::Success){
            cout<<"Ping task server ok.."<<endl;
        }else{
            cout<<"Ping task server fail!"<<endl;
        }


    } catch (SipescException & ex) {
        cout<<ex.errorCode<<","<<ex.why;
    }


    QApplication app(argc, argv);
    LoginDialog loginDialog;
    ClientWindow window;

 if( loginDialog.exec() != QDialog::Accepted){

     Globals::transport->close();
      return -1;
   }

    window.show();
    mainResult = app.exec();

    Globals::transport->close();



  } catch (TException& tx) {
    cout << "ERROR: " << tx.what() << endl;
  }

  return mainResult;
}
Пример #9
0
bool
ServerWindow::ParseEvents (const char *data)
{
	BString firstWord = GetWord(data, 1).ToUpper();
	BString secondWord = GetWord(data, 2).ToUpper();

	if(firstWord == "PING")
	{
		BString tempString,
		        theServer (GetWord(data, 2));
		theServer.RemoveFirst(":");
		
		tempString << "PONG " << myNick << " " << theServer;
		SendData (tempString.String());
		tempString = "";
		tempString << "PONG " << theServer; // fix for some noncompliant servers
		SendData (tempString.String());
		return true;
	}

	if (secondWord == "JOIN")
	{
		BString nick (GetNick (data));
		BString channel (GetWord (data, 3));

		channel.RemoveFirst (":");
		ClientWindow *client (Client (channel.String()));

		if (nick == myNick)
		{
			if (!client)
			{
				client =  new ChannelWindow (
					channel.String(),
					sid,
					serverName.String(),
					sMsgr,
					myNick.String());

				clients.AddItem (client);
				client->Show();
			}
				
			BString tempString ("MODE ");
			tempString << channel;
			SendData (tempString.String());
		}
		else if (client)
		{
			// someone else
			BString ident (GetIdent (data));
			BString address (GetAddress (data));
			const char *expansions[3];
			BString tempString, addy;

			expansions[0] = nick.String();
			expansions[1] = ident.String();
			expansions[2] = address.String();

			tempString = ExpandKeyed (events[E_JOIN], "NIA", expansions);
			BMessage display (M_DISPLAY);
			PackDisplay (
				&display,
				tempString.String(),
				&joinColor,
				0,
				true);

			addy << ident << "@" << address;

			BMessage aMsg (M_IS_IGNORED), reply;
			bool ignored;

			aMsg.AddString ("server", serverName.String());
			aMsg.AddString ("nick", nick.String());
			aMsg.AddString ("address", addy.String());

			be_app_messenger.SendMessage (&aMsg, &reply);
			reply.FindBool ("ignored", &ignored);
			
			BMessage msg (M_USER_ADD);
			msg.AddString ("nick",  nick.String());
			msg.AddBool ("ignore", ignored);
			msg.AddMessage ("display", &display);
			client->PostMessage (&msg);
		}
		return true;
	}
	
	if (secondWord == "PART")
	{
		BString nick (GetNick (data));
		BString channel (GetWord (data, 3));
		ClientWindow *client;

		if ((client = Client (channel.String())) != 0)
		{
			BString ident (GetIdent (data));
			BString address (GetAddress (data));
			const char *expansions[3];
			BString buffer;

			expansions[0] = nick.String();
			expansions[1] = ident.String();
			expansions[2] = address.String();

			buffer = ExpandKeyed (events[E_PART], "NIA", expansions);

			BMessage display (M_DISPLAY);
			PackDisplay (&display, buffer.String(), &joinColor, 0, true);

			BMessage msg (M_USER_QUIT);
			msg.AddString ("nick", nick.String());
			msg.AddMessage ("display", &display);
			client->PostMessage (&msg);
		}

		return true;
	}
	
	if(secondWord == "PRIVMSG")
	{
		BString theNick (GetNick (data)),
			ident (GetIdent (data)),
			address (GetAddress (data)),
			addy;


		addy << ident << "@" << address;
		BMessage aMsg (M_IS_IGNORED), reply;
		bool ignored;

		aMsg.AddString ("server", serverName.String());
		aMsg.AddString ("nick", theNick.String());
		aMsg.AddString ("address", addy.String());

		be_app_messenger.SendMessage (&aMsg, &reply);
		reply.FindBool ("ignored", &ignored);

		if (ignored)
		{
			BMessage msg (M_IGNORED_PRIVMSG);
			const char *rule;

			reply.FindString ("rule", &rule);
			msg.AddString ("nick", theNick.String());
			msg.AddString ("address", addy.String());
			msg.AddString ("rule", rule);
			Broadcast (&msg);
			return true;
		}

		BString theTarget (GetWord (data, 3).ToUpper()),
		        theTargetOrig (GetWord (data, 3)),
		        theMsg (RestOfString (data, 4));
		ClientWindow *client (0);

		theMsg.RemoveFirst(":");

		if(theMsg[0] == '\1' && GetWord(theMsg.String(), 1) != "\1ACTION") // CTCP
		{
			ParseCTCP (theNick, theTargetOrig, theMsg);
			return true;
		}

		if (theTarget[0] == '#')
			client = Client (theTarget.String());
		else if (!(client = Client (theNick.String())))
		{
			BString ident = GetIdent(data);
			BString address = GetAddress(data);
			BString addyString;
			addyString << ident << "@" << address;

			client = new MessageWindow (
				theNick.String(),
				sid,
				serverName.String(),
				sMsgr,
				myNick.String(),
				addyString.String(),
				false, // not a dcc chat
				true); // initated by server

			clients.AddItem (client);
			client->Show();
		}

		if (client) client->ChannelMessage (
			theMsg.String(),
			theNick.String(),
			ident.String(),
			address.String());

		return true;
	}
	
	if (secondWord == "NICK")
	{
		BString oldNick (GetNick (data)),
		        ident (GetIdent (data)),
		        address (GetAddress (data)),
		        newNick (GetWord (data, 3)),
		        buffer;
		const char *expansions[4];

		newNick.RemoveFirst (":");

		expansions[0] = oldNick.String();
		expansions[1] = newNick.String();
		expansions[2] = ident.String();
		expansions[3] = address.String();

		buffer = ExpandKeyed (events[E_NICK], "NnIA", expansions);
		BMessage display (M_DISPLAY);
		PackDisplay (&display, buffer.String(), &nickColor, 0, bowser_app->GetStampState());

		BMessage msg (M_CHANGE_NICK);
		msg.AddString ("oldnick", oldNick.String());
		msg.AddString ("newnick", newNick.String());
		msg.AddString ("ident", ident.String());
		msg.AddString ("address", address.String());
		msg.AddMessage ("display", &display);

		Broadcast (&msg);

		// Gotta change the server as well!
		if (myNick.ICompare (oldNick) == 0)
		{
			myNick = newNick;
			status->SetItemValue (STATUS_NICK, newNick.String());
		}

		bowser_app->PostMessage (&msg); // for ignores

		return true;
	}

	if (secondWord == "QUIT")
	{
		BString theNick (GetNick (data).String()),
		        theRest (RestOfString (data, 3)),
		        ident (GetIdent (data)),
		        address (GetAddress (data)),
		        theMsg,
		        firstNick;
		const char *expansions[4];

		theRest.RemoveFirst (":");
		
		expansions[0] = theNick.String();
		expansions[1] = theRest.String();
		expansions[2] = ident.String();
		expansions[3] = address.String();

		theMsg = ExpandKeyed (events[E_QUIT], "NRIA", expansions);
		BMessage display (M_DISPLAY);
		PackDisplay (&display, theMsg.String(), &quitColor, 0, true);

		BMessage msg (M_USER_QUIT);
		msg.AddMessage ("display", &display);
		msg.AddString ("nick", theNick.String());

		Broadcast (&msg);
		
		// see if it was our first nickname. if so, change
		firstNick = (const char *)lnicks->ItemAt (0);
		if (theNick == firstNick)
		{
			BString tempCmd ("/nick ");
			tempCmd << firstNick;
			ParseCmd (tempCmd.String());
		}
				
		return true;
	}

	if (secondWord == "KICK")
	{
		BString kicker (GetNick (data)),
		        kickee (GetWord (data, 4)),
		        rest (RestOfString (data, 5)),
		        channel (GetWord (data, 3));
		ClientWindow *client (Client (channel.String()));

		rest.RemoveFirst (":");

		if ((client = Client (channel.String())) != 0
		&&   kickee == myNick)
		{
			BMessage display (M_DISPLAY); // "you were kicked"
			BString buffer;

			buffer << "*** You have been kicked from "
				<< channel << " by " << kicker << " (" << rest << ")\n";
			PackDisplay (&display, buffer.String(), &quitColor, 0, true);

			BMessage display2 (M_DISPLAY); // "attempting auto rejoin"
			buffer = "*** Attempting to automagically rejoin ";
			buffer << channel << "...\n";
			PackDisplay (&display2, buffer.String(), &quitColor, 0, true);
						

			BMessage msg (M_CHANNEL_GOT_KICKED);
			msg.AddString ("channel", channel.String());
			msg.AddMessage ("display", &display);  // "you were kicked"
			msg.AddMessage ("display2", &display2); // "attempting auto rejoin"
			client->PostMessage (&msg);
		}

		if (client && kickee != myNick)
		{
			BMessage display (M_DISPLAY);
			const char *expansions[4];
			BString buffer;

			expansions[0] = kickee.String();
			expansions[1] = channel.String();
			expansions[2] = kicker.String();
			expansions[3] = rest.String();

			buffer = ExpandKeyed (events[E_KICK], "NCnR", expansions);
			PackDisplay (&display, buffer.String(), &quitColor, 0, true);

			BMessage msg (M_USER_QUIT);
			msg.AddString ("nick", kickee.String());
			msg.AddMessage ("display", &display);
			client->PostMessage (&msg);
		}

		return true;
	}

	if(secondWord == "TOPIC")
	{
		BString theNick (GetNick (data)),
		        theChannel (GetWord (data, 3)),
		        theTopic (RestOfString (data, 4));
		ClientWindow *client (Client (theChannel.String()));

		theTopic.RemoveFirst (":");

		if (client && client->Lock())
		{
			BString ident (GetIdent (data));
			BString address (GetAddress (data));
			const char *expansions[5];
			BString buffer;

			expansions[0] = theNick.String();
			expansions[1] = theTopic.String();
			expansions[2] = client->Id().String();
			expansions[3] = ident.String();
			expansions[4] = address.String();

			if(bowser_app->GetShowTopicState())
			{
				buffer << client->Id() << " : " << theTopic;
				client->SetTitle (buffer.String());
				client->Unlock();
			}
			else
			{
				buffer << client->Id();
				client->SetTitle (buffer.String());
				client->Unlock();
			}
			
			BMessage topic (M_CHANNEL_TOPIC);
			
			topic.AddString("topic", theTopic.String());
						
			BMessage display (M_DISPLAY);

			buffer = ExpandKeyed (events[E_TOPIC], "NTCIA", expansions);
			PackDisplay (&display, buffer.String(), &whoisColor, 0, true);
			topic.AddMessage("display", &display);
			client->PostMessage (&topic);
		}
		return true;
	}

	if (secondWord == "MODE")
	{
		BString theNick (GetNick (data)),
		        theChannel (GetWord (data, 3)),
		        theMode (GetWord (data, 4)),
		        theTarget (RestOfString (data, 5));
		ClientWindow *client (Client (theChannel.String()));

		if (client)
		{
			BMessage msg (M_CHANNEL_MODE);

			msg.AddString("nick", theNick.String());
			msg.AddString("mode", theMode.String());
			msg.AddString("target", theTarget.String());

			client->PostMessage (&msg);
		}
		else
		{
			BMessage msg (M_DISPLAY);
			BString buffer;
			
			theMode.RemoveFirst(":");
	
			buffer << "*** User mode changed: " << theMode << "\n";
			PackDisplay (&msg, buffer.String(), 0, 0, true);

			PostActive (&msg);
		}

		return true;
	}

	if(firstWord == "NOTICE") // _server_ notice
	{
		BString theNotice (RestOfString(data, 3));
		const char *expansions[1];

		theNotice.RemoveFirst(":");

		expansions[0] = theNotice.String();
		theNotice = ExpandKeyed (events[E_SNOTICE], "R", expansions);
		Display (theNotice.String(), 0, 0, true);

		return true;
	}

	if (firstWord == "ERROR") // server error (on connect?)
	{
		BString theError (RestOfString (data, 2));

		theError.RemoveAll (":");
		theError.Append ("\n");

		Display (theError.String(), &quitColor);
		isConnecting = false;
		return true;
	}

	if(secondWord == "NOTICE") // _user_ notice
	{
		BString theNick (GetNick (data)),
			ident (GetIdent (data)),
			address (GetAddress (data)),
			addy;

		addy << theNick << "@" << address;

		BMessage aMsg (M_IS_IGNORED), reply;
		bool ignored;

		aMsg.AddString ("server", serverName.String());
		aMsg.AddString ("nick", theNick.String());
		aMsg.AddString ("address", addy.String());

		be_app_messenger.SendMessage (&aMsg, &reply);
		reply.FindBool ("ignored", &ignored);

		if (ignored) return true;

		BString theNotice = RestOfString(data, 4);

		theNotice.RemoveFirst(":");

		if(theNotice[0] == '\1')
		{
			ParseCTCPResponse(theNick, theNotice);
			return true;
		}

		const char *expansions[4];
		BString tempString;

		expansions[0] = theNick.String();
		expansions[1] = theNotice.String();
		expansions[2] = ident.String();
		expansions[3] = address.String();

		tempString = ExpandKeyed (events[E_UNOTICE], "NRIA", expansions);
		BMessage display (M_DISPLAY);
		PackDisplay (&display, tempString.String(), &noticeColor, 0, true);
		PostActive (&display);
		return true;
	}

	return ParseENums (data, secondWord.String());
}