コード例 #1
0
ファイル: core.cpp プロジェクト: tr37ion/qTox
void Core::sendGroupMessage(int groupId, const QString& message)
{
    QList<CString> cMessages = splitMessage(message);

    for (auto &cMsg :cMessages)
    {
        int ret = tox_group_message_send(tox, groupId, cMsg.data(), cMsg.size());
        if (ret == -1)
            emit groupSentResult(groupId, message, ret);
    }
}
コード例 #2
0
ファイル: core.cpp プロジェクト: tr37ion/qTox
void Core::sendMessage(int friendId, const QString& message)
{
    QList<CString> cMessages = splitMessage(message);

    for (auto &cMsg :cMessages)
    {
        int messageId = tox_send_message(tox, friendId, cMsg.data(), cMsg.size());
        if (messageId == 0)
            emit messageSentResult(friendId, message, messageId);
    }
}
コード例 #3
0
ファイル: core.cpp プロジェクト: Pik-9/qTox
void Core::sendGroupAction(int groupId, const QString& message)
{
    QList<CString> cMessages = splitMessage(message, MAX_GROUP_MESSAGE_LEN);

    for (auto &cMsg :cMessages)
    {
        int ret = tox_group_action_send(tox, groupId, cMsg.data(), cMsg.size());

        if (ret == -1)
            emit groupSentResult(groupId, message, ret);
    }
}
コード例 #4
0
ファイル: core.cpp プロジェクト: mpxc/qTox
void Core::sendGroupMessageWithType(int groupId, const QString& message, TOX_MESSAGE_TYPE type)
{
    QStringList cMessages = splitMessage(message, MAX_GROUP_MESSAGE_LEN);

    for (auto& part : cMessages) {
        ToxString cMsg(part);
        TOX_ERR_CONFERENCE_SEND_MESSAGE error;
        bool ok = tox_conference_send_message(tox, groupId, type, cMsg.data(), cMsg.size(), &error);
        if (ok && error == TOX_ERR_CONFERENCE_SEND_MESSAGE_OK) {
            return;
        }

        qCritical() << "Fail of tox_conference_send_message";
        switch (error) {
        case TOX_ERR_CONFERENCE_SEND_MESSAGE_CONFERENCE_NOT_FOUND:
            qCritical() << "Conference not found";
            return;

        case TOX_ERR_CONFERENCE_SEND_MESSAGE_FAIL_SEND:
            qCritical() << "Conference message failed to send";
            return;

        case TOX_ERR_CONFERENCE_SEND_MESSAGE_NO_CONNECTION:
            qCritical() << "No connection";
            return;

        case TOX_ERR_CONFERENCE_SEND_MESSAGE_TOO_LONG:
            qCritical() << "Meesage too long";
            return;

        default:
            break;
        }

        emit groupSentResult(groupId, message, -1);
    }
}
コード例 #5
0
SimpleDialog::SimpleDialog(QWidget *parent, ESD_TYPE_E type, int btn_mask, const char *msg_format, va_list ap) :
#if (QT_VERSION > QT_VERSION_CHECK(5, 2, 0))
    check_box_(0),
#endif
    message_box_(0)
{
    gchar *vmessage;
    QString message;

    vmessage = g_strdup_vprintf(msg_format, ap);
    message = QTextCodec::codecForLocale()->toUnicode(vmessage);
    g_free(vmessage);

    MessagePair msg_pair = splitMessage(message);
    // Remove leading and trailing whitespace along with excessive newline runs.
    QString primary = msg_pair.first.trimmed();
    QString secondary = msg_pair.second.trimmed();
    secondary.replace(QRegExp("\n\n+"), "\n\n");

    if (primary.isEmpty()) {
        return;
    }

    if (!parent || !wsApp->isInitialized() || wsApp->isReloadingLua()) {
        message_queue_ << msg_pair;
        if (type > max_severity_) {
            max_severity_ = type;
        }
        return;
    }

    message_box_ = new QMessageBox(parent);
    message_box_->setTextFormat(Qt::PlainText);
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
    message_box_->setTextInteractionFlags(Qt::TextSelectableByMouse);
#endif


    switch(type) {
    case ESD_TYPE_ERROR:
        message_box_->setIcon(QMessageBox::Critical);
        break;
    case ESD_TYPE_WARN:
        message_box_->setIcon(QMessageBox::Warning);
        break;
    case ESD_TYPE_CONFIRMATION:
        message_box_->setIcon(QMessageBox::Question);
        break;
    case ESD_TYPE_INFO:
    default:
        message_box_->setIcon(QMessageBox::Information);
        break;
    }

    if (btn_mask & ESD_BTN_OK) {
        message_box_->addButton(QMessageBox::Ok);
    }
    if (btn_mask & ESD_BTN_CANCEL) {
        message_box_->addButton(QMessageBox::Cancel);
    }
    if (btn_mask & ESD_BTN_YES) {
        message_box_->addButton(QMessageBox::Yes);
    }
    if (btn_mask & ESD_BTN_NO) {
        message_box_->addButton(QMessageBox::No);
    }
//    if (btn_mask & ESD_BTN_CLEAR) {
//        addButton(QMessageBox::);
//    }
    if (btn_mask & ESD_BTN_SAVE) {
        message_box_->addButton(QMessageBox::Save);
    }
    if (btn_mask & ESD_BTN_DONT_SAVE) {
        message_box_->addButton(QMessageBox::Discard);
    }
//    if (btn_mask & ESD_BTN_QUIT_DONT_SAVE) {
//        addButton(QMessageBox::);
//    }


    message_box_->setText(primary);
    message_box_->setInformativeText(secondary);
}
コード例 #6
0
int XMessageBox::show()
{
   if (mDisplay == NULL)
      return -1;

   int retVal = 0;
   retVal = loadFont();
   if (retVal < 0)
      return retVal;

   // set the maximum window dimensions
   mScreenWidth = DisplayWidth(mDisplay, DefaultScreen(mDisplay));
   mScreenHeight = DisplayHeight(mDisplay, DefaultScreen(mDisplay));
   mMaxWindowWidth = min(mScreenWidth, MessageBox_MaxWinWidth);
   mMaxWindowHeight = min(mScreenHeight, MessageBox_MaxWinHeight);

   // split the message into a vector of lines
   splitMessage();

   // set the dialog dimensions
   setDimensions();

   mWin = XCreateSimpleWindow(
      mDisplay,
      DefaultRootWindow(mDisplay),
      (mScreenWidth - mMBWidth) / 2,  (mScreenHeight - mMBHeight) / 2,
      mMBWidth, mMBHeight,
      1, 
      BlackPixel(mDisplay, DefaultScreen(mDisplay)),
      WhitePixel(mDisplay, DefaultScreen(mDisplay)));

   mGC = XCreateGC(mDisplay, mWin, 0, 0);

   XSetFont(mDisplay, mGC, mFS->fid);

   // set input mask
   XSelectInput(mDisplay, mWin, 
      ExposureMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask);

   // set wm protocols in case they hit X
   Atom wm_delete_window = 
      XInternAtom(mDisplay, "WM_DELETE_WINDOW", False);
   Atom wm_protocols = 
      XInternAtom(mDisplay, "WM_PROTOCOLS", False);
   XSetWMProtocols (mDisplay, mWin, &wm_delete_window, 1);
   // set pop up dialog hint
   XSetTransientForHint(mDisplay, mWin, mWin);
   
   // set title
   XTextProperty wtitle;
   wtitle.value = (unsigned char *)mTitle;
   wtitle.encoding = XA_STRING;
   wtitle.format = 8;
   wtitle.nitems = strlen(mTitle);
   XSetWMName(mDisplay, mWin, &wtitle);

   // show window
   XMapWindow(mDisplay, mWin);
   // move it in case some bozo window manager repositioned it
   XMoveWindow(mDisplay, mWin, 
      (mScreenWidth - mMBWidth) / 2,  (mScreenHeight - mMBHeight) / 2);
   // raise it to top
   XRaiseWindow(mDisplay, mWin);

   XMessageBoxButton* clickedButton = NULL;
   XEvent event;
   Vector<XMessageBoxButton>::iterator iter;
   bool done = false;
   while (!done)
   {
      XNextEvent(mDisplay, &event);
      switch (event.type)
      {
         case Expose:
            repaint();
            break;
         case MotionNotify:
            for (iter = mButtons.begin(); iter != mButtons.end(); ++iter)
               iter->setMouseCoordinates(event.xmotion.x, event.xmotion.y);
            break;
         case ButtonPress:
            for (iter = mButtons.begin(); iter != mButtons.end(); ++iter)
            {
               if (iter->pointInRect(event.xbutton.x, event.xbutton.y))
               {
                  iter->setMouseDown(true);
                  iter->setMouseCoordinates(event.xbutton.x, event.xbutton.y);
                  break;
               }
            }
            break;
         case ButtonRelease:
            for (iter = mButtons.begin(); iter != mButtons.end(); ++iter)
            {
               if (iter->pointInRect(event.xbutton.x, event.xbutton.y) &&
                  iter->isMouseDown())
               {
                  // we got a winner!
                  clickedButton = iter;
                  done = true;
                  break;
               }
            }
            if (clickedButton == NULL)
            {
               // user released outside a button.  clear the button states
               for (iter = mButtons.begin(); iter != mButtons.end(); ++iter)
                  iter->setMouseDown(false);
            }
            break;
         case ClientMessage:
            if (event.xclient.message_type == wm_protocols &&
               event.xclient.data.l[0] == static_cast<long>(wm_delete_window))
               done = true;
            break;
      }
      repaint();
   }

   XUnmapWindow(mDisplay, mWin);
   XDestroyWindow(mDisplay, mWin);
   XFreeGC(mDisplay, mGC);
   XFreeFont(mDisplay, mFS);

   if (clickedButton != NULL)
      return clickedButton->getClickVal();
   else
      return -1;
}
コード例 #7
0
ChatControlMessageText::ChatControlMessageText(WhatsappMessage &message, int width, Smileys &smileys)
	: ChatControlMessage(message, width), smileys(smileys)
{
	splitMessage(message);
}
コード例 #8
0
ファイル: dll.c プロジェクト: Auzzy/school
int splitFile(message msg, packet** packetList)
{
	return splitMessage(msg,START_FILE,CONT_FILE,END_FILE,packetList);
}
コード例 #9
0
ファイル: dll.c プロジェクト: Auzzy/school
int splitHeader(message msg, packet** packetList)
{
	return splitMessage(msg,START_HEADER,CONT_HEADER,END_HEADER,packetList);
}