Esempio n. 1
0
void
ScreenshotWindow::_SetupTranslatorMenu()
{
	BMessage message(kImageFormat);
	fTranslatorMenu = new BMenu("Please select");
	BTranslationUtils::AddTranslationItems(fTranslatorMenu, B_TRANSLATOR_BITMAP,
		&message, NULL, NULL, NULL);

	fTranslatorMenu->SetLabelFromMarked(true);

	if (fTranslatorMenu->ItemAt(0))
		fTranslatorMenu->ItemAt(0)->SetMarked(true);

	int32 imageFileType;
	for (int32 i = 0; i < fTranslatorMenu->CountItems(); ++i) {
		BMenuItem* item = fTranslatorMenu->ItemAt(i);
		if (item != NULL && item->Message()) {
			item->Message()->FindInt32("be:type", &imageFileType);
			if (fImageFileType == imageFileType) {
				item->SetMarked(true);
				MessageReceived(item->Message());
				break;
			}
		}
	}
}
Esempio n. 2
0
// ------------------------------------------------------------------- RHTML_Preferences_Win - QuitRequested -
bool RHTMLPreferencesWin::QuitRequested()
{
 MessageReceived(new BMessage('DFFN'));
 
 if (!IsQuit) fParent->MessageReceived(new BMessage('PRWQ'));
 return BWindow::QuitRequested();
}
Esempio n. 3
0
bool
WUploadThread::event(QEvent *e)
{
	int t = (int) e->type();
	switch (t)
	{
	case WMessageEvent::MessageEventType:
		{
			WMessageEvent * wme = dynamic_cast<WMessageEvent *>(e);
			if (wme)
			{
				if (wme->MessageType() == WUploadThread::TunnelData)
					MessageReceived(wme->Message(), _sessionID);
				else
					TransferFileList(wme->Message());
			}
			return true;
		}
	case UploadEvent:
		{
			DoUpload();
			return true;
		}
	default:
		{
			return QObject::event(e);
		}
	}
}
Esempio n. 4
0
void CColorSlider::ColorChanged()
{
	Draw(Bounds()) ;
	BMessage msg(msg_SliderChanged);
	msg.AddFloat("value", fValue);
	msg.AddPointer("sender", this);
	MessageReceived(&msg);
}	
Esempio n. 5
0
// ---------------------------------------------------------------------------------- RHTML_text - SetModify -
void RHTMLtext::SetModify(bool kibe)
{
	if (modify != kibe)
	{
		modify = kibe;
		MessageReceived(new BMessage('RTMM'));
	}
	else
		modify=kibe;
}
Esempio n. 6
0
void my_App::MessageReceived(BMessage* fmessage)
{	
	switch (fmessage->what) {
		case 'xxxx':			
		
		break;
		default:
		BApplication:MessageReceived(fmessage);
    }
}
Esempio n. 7
0
void ChatSession::OnMessageReceived(const Tp::ReceivedMessage &message)
{
    QList<Tp::ReceivedMessage> messages;
    messages.append(message);
    tp_text_channel_->acknowledge(messages);

    ChatSessionParticipant* from = GetParticipant(message.sender());
    ChatMessage* m = new ChatMessage(from, message.received(), message.text());
    message_history_.push_back(m);
    emit( MessageReceived(*m) );
}
Esempio n. 8
0
void
ConnectView::Offline()
{
	online = false;
	
	m_pRadioPersonal->SetEnabled(false);
	
	m_pRadioPersonal->SetValue(0);
	m_pRadioIP->SetValue(1);

	MessageReceived(new BMessage(MSG_CONNECTION_MODE));
}
Esempio n. 9
0
/** The Looper's Run() method - which is executed within the context
 * of the Looper's thread - is responsible for listening on the Looper's
 * port. It receives any Message and Pulse which is sent to it.
 *
 * The Looper waits on incoming IPC and handles it on a case-by-case
 * basis. The loop itself is checking Thread's Terminated() flag on
 * each iteration.  Hence, calling Terminate() on the Looper() will not
 * do much until the Looper is woken up by an IPC and it has a chance
 * to check the Terminated() flag.
 *
 * However, you don't want to do this.  Call Quit() instead. It will
 * wrap things up nicely.
 * 
 * \return 0 for a successful finish.
 */
int Looper::Run()
{
   int source_pid;
   int source_port;
   int dest_port;
   uint32 d1,d2,d3,d4,d5,d6;
   int length;


   while ( Terminated() == false  )
   {
      smk_go_dormant();

		// Check for pulses		
      if ( smk_recv_pulse( &source_pid, 
  		    			  &source_port, 
						  &dest_port,
                          &d1, &d2, &d3, &d4, &d5, &d6) == 0 )
      {
      
         Pulse p( d1,d2,d3,d4,d5,d6 );
	       p.source_pid  = source_pid;
	       p.source_port = source_port;
	       p.dest_port   = dest_port;

		   PulseReceived( &p );
      }

      if ( smk_peek_message( &source_pid, &source_port, &dest_port, &length ) == 0 )
      {
	     void *data = malloc( length );

	     if ( smk_recv_message( &source_pid, &source_port, &dest_port, length, data ) >= 0 )
	     {
	        Message *msg = new Message();
			if ( msg->Unflatten( (const char*)data ) != -1 )
			{
			  msg->_source_pid   = source_pid;
			  msg->_source_port  = source_port;
			  msg->_dest_port    = dest_port;
		
			  MessageReceived( msg );
	        }
			delete msg;
	     }

	     free( data );
      }
	   
   }

     return 0;
}
Esempio n. 10
0
void QMessageTransceiverHandler :: HandleIncomingEvent(uint32 code, const MessageRef & next, const IPAddressAndPort & iap)
{
   switch(code)
   {
      case MTT_EVENT_INCOMING_MESSAGE:      emit MessageReceived(next);    break;
      case MTT_EVENT_SESSION_ATTACHED:      emit SessionAttached();        break;
      case MTT_EVENT_SESSION_CONNECTED:     emit SessionConnected(iap);    break;
      case MTT_EVENT_SESSION_DISCONNECTED:  emit SessionDisconnected();    break;
      case MTT_EVENT_SESSION_DETACHED:      emit SessionDetached();        break;
      case MTT_EVENT_OUTPUT_QUEUES_DRAINED: emit OutputQueueDrained(next); break;
   }
   emit InternalHandlerEvent(code, next);  // these get emitted for any event
}
Esempio n. 11
0
void ChatExtension::HandleMessageReceived(const QXmppMessage &message)
{   
    if(message.type() == QXmppMessage::GroupChat)
        return;

    QString sender_jid = jidToBareJid(message.from());
    QString msg = message.body();

    LogInfo("XMPPModule: Received message. From: " + sender_jid.toStdString()
            + " Body: " + msg.toStdString());

    emit MessageReceived(sender_jid, msg);
}
Esempio n. 12
0
void DServer::readSocket(QTcpSocket* pSocket)
{
    QDataStream in(pSocket);

    in.setVersion(QDataStream::Qt_4_5);
    for (;;)
    {
        if (!m_nNextBlockSize)
        {
            if (pSocket->bytesAvailable() < sizeof(quint16)) {break; }
            in >> m_nNextBlockSize;
        }

        if (pSocket->bytesAvailable() < m_nNextBlockSize) { break;  }
        QTime   time;
        int msgtype;
        in >> time >> msgtype;
        QString strMessage ;
        switch(msgtype)
        {
        case msgAction:
            {
                DMWAction action;
                in>>action;
                strMessage =time.toString() + " <Action>"+" button=" + QString::number(action.actionButton)+" x="+QString::number(action.xIndex)+" y="+QString::number(action.yIndex);
                emit ActionReceived(action);
                break;
            }
        case msgString:
            {
                QString str;
                in>>str;
                strMessage =time.toString() + " <Message>" + str;
                emit MessageReceived(str);
                break;
            }
        case msgReplay:
            {
                DMWRePlay* replay=new DMWRePlay();
                in>>replay;
                strMessage =time.toString() + " <Replay>" + " width="+QString::number(replay->width())+"height="+QString::number(replay->height())+" mines="+QString::number(replay->mines())+" scheme="+replay->scheme();
                emit ReplayReceived(replay);
                break;
            }

        }
        m_ptxt->append(strMessage);
        m_nNextBlockSize = 0;
    //    sendMessageToSocket(pClientSocket, "Server Response: Received \"" + str + "\""  );
    }
}
Esempio n. 13
0
void
BMailProtocolConfigView::AddAuthMethod(const char *label,bool needUserPassword)
{
	BMenuField *menu = (BMenuField *)(FindView("auth_method"));
	if (menu != NULL) {
		BMenuItem *item = new BMenuItem(label,new BMessage(needUserPassword ? 'some' : 'none'));

		menu->Menu()->AddItem(item);

		if (menu->Menu()->FindMarked() == NULL) {
			menu->Menu()->ItemAt(0)->SetMarked(true);
			MessageReceived(menu->Menu()->ItemAt(0)->Message());
		}
	}
}
Esempio n. 14
0
void ChatSession::HandlePendingMessage()
{
    QDBusPendingReply<Tp::PendingTextMessageList> pending_messages = tp_text_channel_->textInterface()->ListPendingMessages(true);

    if( !pending_messages.isFinished() )
        pending_messages.waitForFinished();
    if ( pending_messages.isValid() )
    {
        LogDebug("Received pending messages:");
        QDBusMessage m = pending_messages.reply();
        Tp::PendingTextMessageList list = pending_messages.value();
        if (list.size() == 0)
        {
            LogDebug("There is no pending messages.");
        }
        else
        {
            LogDebug(QString("There is ").append(QString::number(list.size())).append(" pending messages.").toStdString());
            for (Tp::PendingTextMessageList::iterator i = list.begin(); i != list.end(); ++i)
            {
                QString note = QString("* Pending message received: ").append(i->text);
                LogDebug(note.toStdString());

                uint type = i->messageType; //! @todo Check if we need value of this parameter
                if (type != Tp::ChannelTextMessageTypeNormal)
                    continue;
                ChatSessionParticipant* originator = GetParticipant(i->sender);
                if (originator == 0)
                {
                    //! @HACK and memory leak here. We should have a contact object from Connection object!
                    //! @HACK We should search contact object with given i->sender id value
                    originator = new ChatSessionParticipant(new Contact(tp_text_channel_->initiatorContact()));
                    participants_.push_back(originator);
                }

                ChatMessage* message = new ChatMessage( originator, QDateTime::fromTime_t(i->unixTimestamp), i->text);
                message_history_.push_back(message);
                emit( MessageReceived(*message) );
            }
        }
    }
    else
        LogError("Received invalid pending messages");
}
Esempio n. 15
0
void
NetworkPrefsView::SaveCurrentNetwork (void)
{
	if (fActiveNetwork.FindString ("name") == NULL)
		return;

	// check real name and fIdent, update if needed
	if (fNickDefaultsBox->Value () == 0)
	{
		const char *curRname (fRealName->Text ());
		if (curRname != NULL)
	{
		if (!fActiveNetwork.HasString ("realname"))
			fActiveNetwork.AddString ("realname", curRname);
		else
			fActiveNetwork.ReplaceString ("realname", curRname);
	}

		const char *curIdent (fIdent->Text ());
		if (curIdent != NULL)
	{
		if (!fActiveNetwork.HasString ("ident"))
			fActiveNetwork.AddString ("ident", curIdent);
		else
			fActiveNetwork.ReplaceString ("ident", curIdent);
	}
	}

	// Not usually the best thing, but lets just do this until we
	// split the functionality into a function.
	BMessage m(M_NETPREFS_TEXT_INVOKE);
	MessageReceived(&m);

	const char *name (fActiveNetwork.FindString ("name"));

	if (!strcmp (fActiveNetwork.FindString ("name"), "defaults"))
	{
		vision_app->SetNetwork ("defaults", &fActiveNetwork);
		return;
	}

	vision_app->SetNetwork (name, &fActiveNetwork);
}
Esempio n. 16
0
// ------------------------------------------------------------------ RHTML_tab_button_str_view - MouseMoved -
void RHTMLtabbuttonstrview::MouseMoved(BPoint point, uint32 transit,const BMessage *message)
{
 if ((Bounds().Contains(point)) && (Window()->IsActive())) {
  if (!fIn)
  {
   BMessage	msg('STT');
   msg.AddPoint("start", ConvertToScreen(point));
   msg.AddRect("bounds", ConvertToScreen(Bounds()));
   msg.AddInt8("num",fTarget->fNum);
   MessageReceived(&msg);
   fIn = true;
  }
 } else
 if (fIn)
 {
  be_app->PostMessage(eToolTipStop);
  fIn = false;
 }
 BView::MouseMoved(point, transit, message);
}
Esempio n. 17
0
void MucExtension::HandleMessageReceived(const QXmppMessage &message)
{
    QXmppMucRoom *room = qobject_cast<QXmppMucRoom*>(sender());
    if(!room)
        return;

    QString message_type;

    // Parse message type into string.
    switch(message.type())
    {
        case QXmppMessage::Error:
            message_type = "error";
            break;
        case QXmppMessage::Normal:
            message_type = "normal";
            break;
        case QXmppMessage::Chat:
            message_type = "chat";
            break;
        case QXmppMessage::GroupChat:
            message_type = "groupchat";
            break;
        case QXmppMessage::Headline:
            message_type = "headline";
            break;
        default:
            message_type = "invalid type";
    }

    LogInfo("XMPPModule: Received message. From: " + message.from().toStdString()
            + " Room: " + room->jid().toStdString()
            + " Body: " + message.body().toStdString()
            + " Type: " + message_type.toStdString());

    emit MessageReceived(room->jid(), message.from(), message.body(), message_type);
}
Esempio n. 18
0
void Slider::KeyDown (const char *bytes, int32 numBytes)
{
	if (numBytes == 1)
	{
		switch (*bytes)
		{
		case B_ESCAPE:
		{
			if (tc)
			{
				// printf ("TextControl is open\n");
				RemoveChild (tc);
				delete (tc);
				tc = NULL;
			}
			break;
		}
		case B_SPACE:
		case B_ENTER:
		{	
			//printf ("Enter\n");
			if (tc)
			{
				// printf ("TextControl is open\n");
				BMessage *key = new BMessage ('tcVC');
				MessageReceived (key);
				delete key;
			}
			else
			{
				knobpos = BPoint (float (value - min)/(max - min)*(width - knobsize), 1);
				BRect kbr = BRect (knobpos.x + sep, knobpos.y, knobpos.x + knobsize - 2 + sep, knobpos.y + height - 3);
		//		kbr.PrintToStream();
				tc = new BTextControl (kbr, "slider value field", "", "", new BMessage ('tcVC'));
				tc->SetTarget (this);
				tc->SetDivider (0);
				EnterFilter *filter = new EnterFilter (this);
				tc->TextView()->AddFilter (filter);
				char vs[64];
				sprintf (vs, fmt, value);
				tc->SetText (vs);
				AddChild (tc);
				tc->MakeFocus (true);
				inherited::KeyDown (bytes, numBytes);
			}
			break;
		}
		case B_LEFT_ARROW:
			//printf ("Left\n");
			if (value > min)
			{
				value -= step;
				Invalidate();
				NotifyTarget();
			}
			break;
		case B_RIGHT_ARROW:
			//printf ("Right\n");
			if (value < max)
			{
				value += step;
				Invalidate();
				NotifyTarget();
			}
			break;
		case B_TAB:
			// printf ("Tab\n");
			if (tc)
			{
				// printf ("TextControl is open\n");
				BMessage *key = new BMessage ('tcVC');
				MessageReceived (key);
				delete key;
			}
			else
			{
			// MakeFocus (false);
				inherited::KeyDown (bytes, numBytes);
				Invalidate();
				break;
			}
		default:
			inherited::KeyDown (bytes, numBytes);
		}
	}
	else
		inherited::KeyDown (bytes, numBytes);
}
Esempio n. 19
0
void MonthWindowView::KeyDown(const char *bytes, int32 numBytes)
{
 switch(bytes[0])
 {
  case B_TAB:
  {
   Bmp->Lock();
   switch(which_focused)
   {
    case 0: // months
    {
     BmpView->SetHighColor(VIEW_COLOR);
     BmpView->StrokeLine(BPoint(monthMStringView[0]->Frame().left,
                                monthMStringView[0]->Frame().bottom+1),
                         BPoint(monthMStringView[1]->Frame().right,
                                monthMStringView[1]->Frame().bottom+1));
     BmpView->SetHighColor(0,0,0);
     break;
    }
    case 1: // years
    {
     BmpView->SetHighColor(VIEW_COLOR);
     BmpView->StrokeLine(BPoint(yearMStringView[0]->Frame().left,
                                yearMStringView[0]->Frame().bottom+1),
                         BPoint(yearMStringView[1]->Frame().right,
                                yearMStringView[1]->Frame().bottom+1));
     BmpView->SetHighColor(0,0,0);
     break;
    }
    case 2: // days of month
    {
     BmpView->SetHighColor(NOACTIVE_COLOR);
     BmpView->StrokeRect(cursor);
     BmpView->SetHighColor(0,0,0);
     break;
    }
    case 3: // today
    {
     BmpView->SetHighColor(VIEW_COLOR);
     BmpView->StrokeLine(BPoint(todayStringView->Frame().left,
                                todayStringView->Frame().bottom+1),
                         BPoint(todayStringView->Frame().right,
                                todayStringView->Frame().bottom+1));
     BmpView->SetHighColor(0,0,0);
     break;
    }
   }
   
   // changing which_focused
   if(modifiers() & B_SHIFT_KEY)
   {
    if(which_focused==0)
      which_focused=3;
    else which_focused--;
   }
   else // simply Tab
   {
    if(which_focused==3)
     which_focused=0;
    else which_focused++;
   }
   
   // drawing with new which_focused
   switch(which_focused)
   {
    case 0: // months
    {
     BmpView->SetHighColor(ACTIVE_COLOR);
     BmpView->StrokeLine(BPoint(monthMStringView[0]->Frame().left,
                                monthMStringView[0]->Frame().bottom+1),
                         BPoint(monthMStringView[1]->Frame().right,
                                monthMStringView[1]->Frame().bottom+1));
     BmpView->SetHighColor(0,0,0);
     break;
    }
    case 1: // years
    {
     BmpView->SetHighColor(ACTIVE_COLOR);
     BmpView->StrokeLine(BPoint(yearMStringView[0]->Frame().left,
                                yearMStringView[0]->Frame().bottom+1),
                         BPoint(yearMStringView[1]->Frame().right,
                                yearMStringView[1]->Frame().bottom+1));
     BmpView->SetHighColor(0,0,0);
     break;
    }
    case 2: // days of month
    {
     BmpView->SetHighColor(ACTIVE_COLOR);
     BmpView->StrokeRect(cursor);
     BmpView->SetHighColor(0,0,0);
     break;
    }
    case 3: // today
    {
     BmpView->SetHighColor(ACTIVE_COLOR);
     BmpView->StrokeLine(BPoint(todayStringView->Frame().left,
                                todayStringView->Frame().bottom+1),
                         BPoint(todayStringView->Frame().right,
                                todayStringView->Frame().bottom+1));
     BmpView->SetHighColor(0,0,0);
     break;
    }
   }
   BmpView->Sync();
   Bmp->Unlock();
   Draw(Bounds());
   break;
  } // B_TAB
  
  case B_DOWN_ARROW:
  {
   if(which_focused==0) // month
   { 
    BMessage msg('MON0');
    MessageReceived(&msg);
   }
   else if(which_focused==1) // year
   {
    BMessage msg('YEA0');
    MessageReceived(&msg);
   }
   else if(which_focused==2) // days of month
   {
    int qu_days=monthDays[cmonth-1];
    if(cmonth==2) if(cyear%4==0) if((cyear%100!=0) || (cyear%400==0)) qu_days=29;
    if((cday+7)<=qu_days)
    {
     Bmp->Lock();
     BmpView->SetHighColor(VIEW_COLOR);
     BmpView->StrokeRect(cursor);
     cursor.OffsetBySelf(0, h_cell);
     cday+=7;
     BmpView->SetHighColor(ACTIVE_COLOR);
     BmpView->StrokeRect(cursor);
     BmpView->SetHighColor(0,0,0);
     BmpView->Sync();
     Bmp->Unlock();
     Draw(Bounds());
    }
   }
   break;
  }
  
  case B_UP_ARROW:
  {
   // Test whether Ctrl+UpArrow is pressed
   if(modifiers() & B_CONTROL_KEY)
    Window()->PostMessage(B_QUIT_REQUESTED);
   else
   {
    if(which_focused==0) // month
    {
     BMessage msg('MON1');
     MessageReceived(&msg);
    }
    else if(which_focused==1) // year
    {
     BMessage msg('YEA1');
     MessageReceived(&msg);
    }
    else if(which_focused==2) // days of month
    {
     if((cday-7)>=1)
     {
      Bmp->Lock();
      BmpView->SetHighColor(VIEW_COLOR);
      BmpView->StrokeRect(cursor);
      cursor.OffsetBySelf(0, -h_cell);
      cday-=7;
      BmpView->SetHighColor(ACTIVE_COLOR);
      BmpView->StrokeRect(cursor);
      BmpView->SetHighColor(0,0,0);
      BmpView->Sync();
      Bmp->Unlock();
      Draw(Bounds());
     }
    }
   }
   break;
  }
  
  case B_LEFT_ARROW:
  {
   if(which_focused==0) // month
   {
    BMessage msg('MON0');
    MessageReceived(&msg);
   }
   else if(which_focused==1) // year
   {
    BMessage msg('YEA0');
    MessageReceived(&msg);
   }
   else if(which_focused==2) // days of month
   {
    if(cday>1)
    {
     Bmp->Lock();
     BmpView->SetHighColor(VIEW_COLOR);
     BmpView->StrokeRect(cursor);
     if(cwday>0) // by dates no matter of day of week
     {
      cursor.OffsetBySelf(-w_cell,0);
      cwday--;
     }
     else // cwday==0
     {
      cursor.OffsetBySelf(w_cell*6,-h_cell);
      cwday=6;
     }
     cday--;
     BmpView->SetHighColor(ACTIVE_COLOR);
     BmpView->StrokeRect(cursor);
     BmpView->SetHighColor(0,0,0);
     BmpView->Sync();
     Bmp->Unlock();
     Draw(Bounds());
    }
    else // 1st of month, go month before
    {
     if(cyear>first_year || cmonth>1) // one can go
     {
      int cm=(cmonth==1) ? 12 : cmonth-1;
      int qu_days=monthDays[cm-1];
      if(cm==2) if(cyear%4==0) 
       if((cyear%100!=0) || (cyear%400==0)) qu_days=29;
       // it is correct not to pay attention to year changing
       // because if we moved to february then year was not changed
       // but if month is other then february 
       // then it has the same number of days every year.
      cday=qu_days;
      
      BMessage msg('MON0');
      MessageReceived(&msg); // here month, cwday and year (if needed) will be changed
     }
    }
   }
   break;
  }
  
  case B_RIGHT_ARROW:
  {
   if(which_focused==0) // month
   {
    BMessage msg('MON1');
    MessageReceived(&msg);
   }
   else if(which_focused==1) // year
   {
    BMessage msg('YEA1');
    MessageReceived(&msg);
   }
   else if(which_focused==2) // days of month
   {
    int qu_days=monthDays[cmonth-1];
    if(cmonth==2) if(cyear%4==0) if((cyear%100!=0) || (cyear%400==0)) qu_days=29;
    if(cday<qu_days)
    {
     Bmp->Lock();
     BmpView->SetHighColor(VIEW_COLOR);
     BmpView->StrokeRect(cursor);
     if(cwday<6) // by dates no matter of day of week
     {
      cursor.OffsetBySelf(w_cell,0);
      cwday++;
     }
     else // cwday==6
     {
      cursor.OffsetBySelf(-w_cell*6,h_cell);
      cwday=0;
     }
     cday++;
     BmpView->SetHighColor(ACTIVE_COLOR);
     BmpView->StrokeRect(cursor);
     BmpView->SetHighColor(0,0,0);
     BmpView->Sync();
     Bmp->Unlock();
     Draw(Bounds());
    }
    else // last of month, go next month
    {
     if(cyear<last_year || cmonth<12) // one can go
     {
      cday=1;
      BMessage msg('MON1');
      MessageReceived(&msg); // here month, cwday and year (if needed) will be changed
     }
    }
   }
   break;
  }
  
  case B_ESCAPE:
  {
   Window()->PostMessage(B_QUIT_REQUESTED);
   break;
  }
  
  case B_ENTER:
  {
   if(which_focused==2)
   {
    // here it is needed to send dayPressed (==cwday), cyear, cmonth
    // to window and leave
    BMessage *msg=new BMessage('MVME');
    msg->AddInt32("day",cday);
    msg->AddInt32("month",cmonth);
    msg->AddInt32("year",cyear);
    Window()->PostMessage(msg);
   }
   else if(which_focused==3)
   {
    BMessage msg('TODA');
    MessageReceived(&msg);
   }
   break;
  }
  
  case B_SPACE: // the same as B_ENTER
  {
   if(which_focused==2)
   {
    // here it is needed to send dayPressed (==cwday), cyear, cmonth
    // to window and leave
    BMessage *msg=new BMessage('MVME');
    msg->AddInt32("day",cday);
    msg->AddInt32("month",cmonth);
    msg->AddInt32("year",cyear);
    Window()->PostMessage(msg);
   }
   else if(which_focused==3)
   {
    BMessage msg('TODA');
    MessageReceived(&msg);
   }
   break;
  }
  
  default: 
   BView::KeyDown(bytes, numBytes);
 }
}
Esempio n. 20
0
BamKeysPrefsWindow::BamKeysPrefsWindow()
	: BWindow(BRect(40, 30, 40 + WIDTH, 30 + HEIGHT), "BamKeys",
			B_TITLED_WINDOW, B_NOT_ZOOMABLE)// | B_NOT_RESIZABLE)
{
	fModified = false;
	fRootView = new BBox(BRect(0, 0, WIDTH, HEIGHT), 
						"root_view", B_FOLLOW_ALL, B_WILL_DRAW, B_PLAIN_BORDER);
	
	fRootView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	AddChild(fRootView);
	
	// Screen area selection box
	fScreenBox = new BBox(BRect(10, 10, ((WIDTH / 3) * 2) - 5, (HEIGHT - 50)), 
						"screen_box", B_FOLLOW_ALL, B_WILL_DRAW, B_FANCY_BORDER);
	BRect gridRect = fScreenBox->Frame();
	gridRect.OffsetTo(0, 0);
	gridRect.InsetBy(5, 5);
	fGrid = new BamKeysGridControl(gridRect, "screen_grid", "", new BMessage('grid'));
	fScreenBox->AddChild(fGrid);
	
	// Settings Box
	fSettingBox = new BBox(BRect(((WIDTH / 3) * 2) + 5, 10, WIDTH - 10, (HEIGHT - 50)),
						"settings_box", B_FOLLOW_RIGHT | B_FOLLOW_TOP_BOTTOM, B_WILL_DRAW, B_FANCY_BORDER);
	
	BRect itmRect = fSettingBox->Frame();
	itmRect.Set(5, 10, itmRect.Width() - 5, (itmRect.Height() - 10) / 8);
	
	// Filter Enabled
	fChkEnabled = new BCheckBox(itmRect, "chkGrid", "Enable BamKeys", new BMessage('fltr'), B_FOLLOW_TOP | B_FOLLOW_RIGHT);
	fChkEnabled->SetValue(fGrid->IsFiltering() ? B_CONTROL_ON : B_CONTROL_OFF);
	fSettingBox->AddChild(fChkEnabled);
	
	itmRect.OffsetBy(0, itmRect.Height());

	// Rows and Columns
	int32 rows;
	int32 columns;
	fGrid->GetSize(&rows, &columns);
	
	BPopUpMenu *mnuRows = new BPopUpMenu("");
	for (int i = 1; i <= MAX_DIVIDE; i++) {
		BString numb("");
		numb << i;
		BMenuItem *mnuItem = new BMenuItem(numb.String(), new BMessage('rowC'));
		mnuRows->AddItem(mnuItem);
		if (i == rows) {
			mnuItem->SetMarked(true);
		}
	}
	
	fMnuFldRows = new BMenuField(itmRect, "mnuRows", "Rows:", mnuRows, B_FOLLOW_TOP | B_FOLLOW_RIGHT);
	fSettingBox->AddChild(fMnuFldRows);
	
	
	itmRect.OffsetBy(0, itmRect.Height());
	
	BPopUpMenu *mnuColumns = new BPopUpMenu("");
	for (int i = 1; i <= MAX_DIVIDE; i++) {
		BString numb("");
		numb << i;
		BMenuItem *mnuItem = new BMenuItem(numb.String(), new BMessage('colC'));
		mnuColumns->AddItem(mnuItem);
		if (i == columns) {
			mnuItem->SetMarked(true);
		}
	}
	
	fMnuFldColumns = new BMenuField(itmRect, "mnuCols", "Columns:", mnuColumns, B_FOLLOW_TOP | B_FOLLOW_RIGHT);
	fSettingBox->AddChild(fMnuFldColumns);
	
	itmRect.OffsetBy(0, itmRect.Height());
	// Hotkey
	BRect stringRect(itmRect);
	stringRect.OffsetBy(0, -(itmRect.Height() / 3));
	fStrHotKey = new BStringView(stringRect, "lblModifiers", "Modifiers:", B_FOLLOW_TOP | B_FOLLOW_LEFT);
	fSettingBox->AddChild(fStrHotKey);
	itmRect.OffsetBy(0, itmRect.Height());

	// Caps Lock
	fCapsLock = new BamKeysKeyView(itmRect, "capsLock", B_CAPS_LOCK, B_FOLLOW_TOP | B_FOLLOW_LEFT);
	fSettingBox->AddChild(fCapsLock);
	itmRect.OffsetBy(0, itmRect.Height());
	
	// Num Lock
	fNumLock = new BamKeysKeyView(itmRect, "numLock", B_NUM_LOCK, B_FOLLOW_TOP | B_FOLLOW_LEFT);
	fSettingBox->AddChild(fNumLock);
	itmRect.OffsetBy(0, itmRect.Height());

	// Scroll Lock
	fScrlLock = new BamKeysKeyView(itmRect, "scrollLock", B_SCROLL_LOCK, B_FOLLOW_TOP | B_FOLLOW_LEFT);
	fSettingBox->AddChild(fScrlLock);
	itmRect.OffsetBy(0, itmRect.Height());
	
	BPoint half = itmRect.RightBottom();
	
	half.x = half.x / 2;
	itmRect.SetRightBottom(half);
	
	// Command Keys
	fLeftCommand = new BamKeysKeyView(itmRect, "leftCommand", B_LEFT_COMMAND_KEY, B_FOLLOW_TOP | B_FOLLOW_LEFT);
	fSettingBox->AddChild(fLeftCommand);
	itmRect.OffsetBy((itmRect.Width() + 5), 0);
	
	fRightCommand = new BamKeysKeyView(itmRect, "rightCommand", B_RIGHT_COMMAND_KEY, B_FOLLOW_TOP | B_FOLLOW_LEFT);
	fSettingBox->AddChild(fRightCommand);
	itmRect.OffsetBy(-(itmRect.Width() + 5), itmRect.Height());
	
	// Ctrl Keys
	fLeftControl = new BamKeysKeyView(itmRect, "leftControl", B_LEFT_CONTROL_KEY, B_FOLLOW_TOP | B_FOLLOW_LEFT);
	fSettingBox->AddChild(fLeftControl);
	itmRect.OffsetBy((itmRect.Width() + 5), 0);
	
	fRightControl = new BamKeysKeyView(itmRect, "rightControl", B_RIGHT_CONTROL_KEY, B_FOLLOW_TOP | B_FOLLOW_LEFT);
	fSettingBox->AddChild(fRightControl);
	itmRect.OffsetBy(-(itmRect.Width() + 5), itmRect.Height());
	
	// Option Keys
	fLeftOption = new BamKeysKeyView(itmRect, "leftOption", B_LEFT_OPTION_KEY, B_FOLLOW_TOP | B_FOLLOW_LEFT);
	fSettingBox->AddChild(fLeftOption);
	itmRect.OffsetBy((itmRect.Width() + 5), 0);
	
	fRightOption = new BamKeysKeyView(itmRect, "rightOption", B_RIGHT_OPTION_KEY, B_FOLLOW_TOP | B_FOLLOW_LEFT);
	fSettingBox->AddChild(fRightOption);
	itmRect.OffsetBy(-(itmRect.Width() + 5), itmRect.Height());
	
	// Shift Keys
	fLeftShift = new BamKeysKeyView(itmRect, "leftShift", B_LEFT_SHIFT_KEY, B_FOLLOW_TOP | B_FOLLOW_LEFT);
	fSettingBox->AddChild(fLeftShift);
	itmRect.OffsetBy((itmRect.Width() + 5), 0);
	
	fRightShift = new BamKeysKeyView(itmRect, "rightShift", B_RIGHT_SHIFT_KEY, B_FOLLOW_TOP | B_FOLLOW_LEFT);
	fSettingBox->AddChild(fRightShift);
	itmRect.OffsetBy(-(itmRect.Width() + 5), itmRect.Height());
	
	
	// Buttons that do things!
	fBtnDefaults = new BButton(BRect(10, HEIGHT - 35, 85, HEIGHT - 15), 
							"btn_defaults", "Defaults", new BMessage('deft'),
							B_FOLLOW_BOTTOM | B_FOLLOW_LEFT);
	fBtnRevert = new BButton(BRect(95, HEIGHT - 35, 170, HEIGHT - 15),
							"btn_revert", "Revert", new BMessage('revt'),
							B_FOLLOW_BOTTOM | B_FOLLOW_LEFT);
	
	fRootView->AddChild(fScreenBox);
	fRootView->AddChild(fSettingBox, fScreenBox);
	fRootView->AddChild(fBtnDefaults, fSettingBox);
	fRootView->AddChild(fBtnRevert, fBtnDefaults);
	
	// If the fGrid couldn't load it settings, force our applications' defaults.
	if (fGrid->InitCheck() != B_OK) {
		BMessage *defaults = new BMessage('deft');
		MessageReceived(defaults);
		fGrid->SaveSettings();
		delete defaults;
		fModified = false;
	}
	fBtnRevert->SetEnabled(fModified);
}
Esempio n. 21
0
void QMessageTransceiverThread :: HandleQueuedIncomingEvents()
{
   uint32 code;
   MessageRef next;
   String sessionID;
   uint32 factoryID;
   bool seenIncomingMessage = false;
   IPAddressAndPort iap;

   // Check for any new messages from our internal thread
   while(GetNextEventFromInternalThread(code, &next, &sessionID, &factoryID, &iap) >= 0)
   {
      switch(code)
      {
         case MTT_EVENT_INCOMING_MESSAGE: default:
            if (seenIncomingMessage == false)
            {
               seenIncomingMessage = true;
               emit BeginMessageBatch();
            }
            emit MessageReceived(next, sessionID); 
         break;

         case MTT_EVENT_SESSION_ACCEPTED:      emit SessionAccepted(sessionID, factoryID, iap); break;
         case MTT_EVENT_SESSION_ATTACHED:      emit SessionAttached(sessionID);                 break;
         case MTT_EVENT_SESSION_CONNECTED:     emit SessionConnected(sessionID, iap);           break;
         case MTT_EVENT_SESSION_DISCONNECTED:  emit SessionDisconnected(sessionID);             break;
         case MTT_EVENT_SESSION_DETACHED:      emit SessionDetached(sessionID);                 break;
         case MTT_EVENT_FACTORY_ATTACHED:      emit FactoryAttached(factoryID);                 break;
         case MTT_EVENT_FACTORY_DETACHED:      emit FactoryDetached(factoryID);                 break;
         case MTT_EVENT_OUTPUT_QUEUES_DRAINED: emit OutputQueuesDrained(next);                  break;
         case MTT_EVENT_SERVER_EXITED:         emit ServerExited();                             break;
      }
      emit InternalThreadEvent(code, next, sessionID, factoryID);  // these get emitted for any event

      const char * id = _handlers.HasItems() ? strchr(sessionID()+1, '/') : NULL;
      if (id)
      {
         QMessageTransceiverHandler * handler;
         if (_handlers.Get(atoi(id+1), handler) == B_NO_ERROR)
         {
            // If it's not already in the list, prepend it to the list and tell it to emit its BeginMessageBatch() signal
            if ((code == MTT_EVENT_INCOMING_MESSAGE)&&(handler != _lastSeenHandler)&&(handler->_nextSeen == NULL))
            {
               if (_firstSeenHandler == NULL) _firstSeenHandler = _lastSeenHandler = handler;
               else
               {
                  _firstSeenHandler->_prevSeen = handler;
                  handler->_nextSeen = _firstSeenHandler;
                  _firstSeenHandler = handler;
               }
               handler->EmitBeginMessageBatch();
            }
            handler->HandleIncomingEvent(code, next, iap);
         }
      }
   }

   FlushSeenHandlers(true);

   if (seenIncomingMessage) emit EndMessageBatch();
}
Esempio n. 22
0
 void MessageHandler::EmitMessageReceivedSignal() {
     emit MessageReceived();
 }
Esempio n. 23
0
void SkyNet::emit_MessageReceived(QByteArray from, QString msg)
{
emit MessageReceived(from, msg);
}
int XmppMessageReciveTask::ProcessStart(void)
{
    static buzz::StaticQName QN_DELAY = { "urn:xmpp:delay", "delay" };

    // 获取下一个stanza
    const auto stanza = NextStanza();
    if (stanza == nullptr)
    {
        return STATE_BLOCKED;
    }

    // 获取消息体
    const auto body = stanza->FirstNamed(buzz::QN_BODY);
    if (body == nullptr)
    {
        return STATE_BLOCKED;
    }

    XmppMessageInfo message;

    // 消息id
    message.SetUid(Utf8ToWStr(stanza->Attr(buzz::QN_ID)));
    // 消息类型
    message.SetType(Utf8ToWStr(stanza->Attr(buzz::QN_TYPE)));

    // 获取发送人
    std::wstring from(Utf8ToWStr(stanza->Attr(buzz::QN_FROM)));
    message.SetFrom(from);
    message.SetFromResource(from);

    // 获取接收人
    message.SetTo(Utf8ToWStr(stanza->Attr(buzz::QN_TO)));
    message.SetToResource(Utf8ToWStr(stanza->Attr(buzz::QN_TO)));

    // 获取消息
    message.SetContent(conv.from_bytes(body->BodyText()));

    // 获取时间
    const auto delay = stanza->FirstNamed(QN_DELAY);
    if (delay != nullptr)
    {
        message.SetTime(Utf8ToWStr(delay->Attr(buzz::kQnStamp)));
    }

    // 是否离线消息
    message.SetIsOfflineMsg(delay != nullptr);

    // 获取主题
    const auto subject = stanza->FirstNamed(buzz::QN_SUBJECT);
    if (subject != nullptr)
    {
        message.SetSubject(Utf8ToWStr(subject->BodyText()));

        // 主题数据
        if (subject->HasAttr(buzz::QN_VALUE))
        {
            message.SetSubjectValue(Utf8ToWStr(subject->Attr(buzz::QN_VALUE)));
        }
    }

    // 获取扩展数据
    auto extention = stanza->FirstNamed(QN_EXTENTION);
    if (extention != nullptr)
    {
        std::map<std::wstring, std::wstring> mapValue;

        auto elChild = extention->FirstElement();
        while (elChild != nullptr)
        {
            auto name = elChild->Name().LocalPart();
            mapValue.emplace(Utf8ToWStr(name), Utf8ToWStr(elChild->BodyText().c_str()));

            elChild = elChild->NextElement();
        }

        message.SetExtention(mapValue);
    }

    MessageReceived(message);

    return STATE_START;
}
Esempio n. 25
0
void ColorsPreflet::MessageReceived(BMessage *msg)
{
	switch(msg->what)
	{
		case M_POINTSIZE_CHANGED:
		{
			int newsize = fFontSize->Value();
			MainWindow->main.editarea->SetFontSize(newsize);
			
			fParent->SettingsChanged();
		}
		break;
		
		case M_SCHEMESEL_CHANGED:
		{			
			int32 newindex;
			msg->FindInt32("newindex", &newindex);
			
			if (CurrentColorScheme.GetLoadedSchemeIndex() == newindex)
				break;
			
			BMenuItem *item = fSchemeMenu->ItemAt(newindex);
			if (item) item->SetMarked(true);
			
			CurrentColorScheme.SaveScheme();
			CurrentColorScheme.LoadScheme(newindex);
			
			editor.curev->FullRedrawView();
			
			fColorsList->ResetRevertBuffer();
			ReloadSettings();
		}
		break;
		
		case M_SCHEME_DELETE:
		{
			int numschemes = ColorScheme::GetNumColorSchemes();
			
			if (numschemes <= 1)
			{
				(new BAlert("", "Cannot delete that color scheme. There must always least one scheme available.", "OK", NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go();
				break;
			}
			
			BString prompt;
			prompt << "Are you sure you want to delete the scheme \"" <<
				CurrentColorScheme.GetSchemeName() << "\"?";
			
			BAlert *alert = new BAlert("", prompt.String(), "No", "Yes");
			if (alert->Go())
			{
				int newindex;
				int curscheme = CurrentColorScheme.GetLoadedSchemeIndex();
				
				// make some other scheme active
				if (curscheme == numschemes - 1)
					newindex = curscheme - 1;
				else
					newindex = curscheme + 1;
				
				BMessage msg(M_SCHEMESEL_CHANGED);
				msg.AddInt32("newindex", newindex);
				MessageReceived(&msg);
				
				// now, delete the scheme
				ColorScheme::DeleteScheme(curscheme);
				
				// fixup loaded index for the deletion
				if (newindex > curscheme)
					CurrentColorScheme.LoadScheme(curscheme);
				
				UpdateSchemesMenu();
				
				fColorsList->ResetRevertBuffer();
				ReloadSettings();
			}
		}
		break;
		
		case M_SCHEME_NEW:
		{
			BString *schemeName;
			BString defaultName(CurrentColorScheme.GetSchemeName());
			defaultName.Append(" Copy");
			
			schemeName = InputBox::Go(MainWindow, "New Scheme", "Name of new scheme:", defaultName.String());
			if (!schemeName) break;
			if (!schemeName->String()[0]) break;
			
			stat("creating new scheme '%s'", schemeName->String());
			
			// duplicate current scheme into the next available index
			CurrentColorScheme.SaveScheme();
			ColorScheme tempscheme = CurrentColorScheme;
			
			int count = ColorScheme::GetNumColorSchemes();
			tempscheme.SetSchemeName(schemeName->String());
			tempscheme.SaveScheme(count);
			
			UpdateSchemesMenu();
			
			// set the new scheme to be active
			CurrentColorScheme.LoadScheme(count);
			BMenuItem *item = fSchemeMenu->ItemAt(count);
			if (item) item->SetMarked(true);
			
			// clean up and we're done
			fColorsList->ResetRevertBuffer();
			delete schemeName;
		}
		break;
		
		case M_SCHEME_DEFAULTS:
		{
			BAlert *alert = new BAlert("", "This will erase all user color-schemes and reset"
										   " colors to the built-in defaults. Is that want you"
										   " want to do?", "Cancel", "Set Defaults", NULL,
										   B_WIDTH_AS_USUAL, B_STOP_ALERT);
			
			if (alert->Go())
			{
				ColorScheme::ResetToDefaults();
				CurrentColorScheme.LoadScheme(1);
				UpdateSchemesMenu();
				
				editor.curev->FullRedrawView();
				
				ReloadSettings();
				
				fColorsList->ResetRevertBuffer();
				fParent->SettingsChanged();
			}
		}
		break;
		
		default:
			MessageView::MessageReceived(msg);
		break;
	}	
}
Esempio n. 26
0
void CColorSlider::MouseDown(BPoint where)
{
	if (!IsFocus())
		MakeFocus(true);
		
	BRect b(Bounds()), knob;
	
	b.InsetBy(1, 1);
	
	float a, s;
	
	knob = b;
	
	if (fHorizontal)
	{
		knob.right = b.left + b.Height();
		a = b.Width() - knob.Width();
		knob.OffsetBy(fValue * a, 0);
		s = where.x - knob.left;
	}
	else
	{
		knob.bottom = b.top + b.Width();
		a = b.Height() - knob.Height();
		knob.OffsetBy(0, (1 - fValue) * a);
		s = where.y - knob.top;
	}
	
	if (knob.Contains(where))
	{
		BPoint oldPt(-1, -1);
		ulong btns;
		BMessage msg(msg_SliderChanged);
		msg.AddFloat("value", fValue);
		msg.AddPointer("sender", this);
		
		do
		{
			if (oldPt != where)
			{
				if (fHorizontal)
					fValue = std::min(1.0F, std::max(0.0F, (where.x - s) / a));
				else
					fValue = 1 - std::min(1.0F, std::max(0.0F, (where.y - s) / a));
				
				msg.ReplaceFloat("value", fValue);
				
				Draw(Bounds());
				MessageReceived(&msg);
				
				oldPt = where;
			}
			
			GetMouse(&where, &btns);
		}
		while (btns);
		
		Window()->PostMessage(msg_EndTracking);
	}
	else // TPV 00-02-27
	{
		float pos , range ;
		if (fHorizontal)
		{
			pos = where.x - knob.Width()/2;
			range = a ;
		}
		else
		{
			pos = a - ( where.y - knob.Width()/2 ) ;
			range = a ;
		}
		if( pos < 0 ) pos = 0 ;
		else if( pos > range ) pos = range ;

		fValue = pos/range ;
		ColorChanged() ;
	}		
} /* CColorSlider::MouseDown */
Esempio n. 27
0
void
AddPrinterView::AttachedToWindow()
{
	// protocol class box
	BBox* protocolClassBox = new BBox("protocolClass");
	protocolClassBox->SetLabel("Protocol classes:");

	// protocol class
	fProtocolClassList = new BListView("protocolClassList");
	fProtocolClassList->SetExplicitMinSize(BSize(500, 200));
	BScrollView* protocolClassScroller = new BScrollView(
		"protocolClassListScroller",
		fProtocolClassList,
		0,
		false,
		true,
		B_NO_BORDER);
	fProtocolClassList->SetSelectionMessage(
		new BMessage(kMsgProtocolClassChanged));
	fProtocolClassList->SetTarget(this);

	protocolClassBox->AddChild(protocolClassScroller);

	int count = fPrinterCap->CountCap(PrinterCap::kProtocolClass);
	ProtocolClassCap **protocolClasses =
		(ProtocolClassCap **)fPrinterCap->GetCaps(PrinterCap::kProtocolClass);
	while (count--) {
		const ProtocolClassCap *protocolClass = *protocolClasses;

		BStringItem* item = new ProtocolClassItem(protocolClass);
		fProtocolClassList->AddItem(item);
		if (protocolClass->fIsDefault) {
			int index = fProtocolClassList->IndexOf(item);
			fProtocolClassList->Select(index);
		}
		protocolClasses ++;
	}

	// description of protocol class box
	BBox* descriptionBox = new BBox("descriptionBox");
	descriptionBox->SetLabel("Description:");

	// description of protocol class
	fDescription = new BTextView("description");
	fDescription->SetExplicitMinSize(BSize(200, 200));
	fDescription->SetViewColor(descriptionBox->ViewColor());
	BScrollView* descriptionScroller = new BScrollView("descriptionScroller",
			fDescription,
			0,
			false,
			true,
			B_NO_BORDER);
	fDescription->MakeEditable(false);

	descriptionBox->AddChild(descriptionScroller);

	// separator line
	BBox *separator = new BBox("separator");
	separator->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1));

	// buttons
	BButton* cancel = new BButton("cancel", "Cancel",
		new BMessage(kMsgCancel));
	BButton* ok = new BButton("ok", "OK", new BMessage(kMsgOK));
	ok->MakeDefault(true);

	SetLayout(new BGroupLayout(B_VERTICAL));
	AddChild(BGroupLayoutBuilder(B_VERTICAL, 0)
		.Add(protocolClassBox)
		.Add(descriptionBox)
		.AddGlue()
		.Add(separator)
		.AddGroup(B_HORIZONTAL, 10, 1.0f)
			.AddGlue()
			.Add(cancel)
			.Add(ok)
		.End()
		.SetInsets(0, 0, 0, 0)
	);


	// update description
	BMessage updateDescription(kMsgProtocolClassChanged);
	MessageReceived(&updateDescription);
}