示例#1
0
static void text_ui_dispatcher(void *ptr)
{
   int ret;
   int oldstate;
   int oldtype;
   struct generic_qnode *n;
   
   DEBUG_MSG("Starting Text UI dispatcher");
   ret = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate);
   ret |= pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
   assert(ret == 0);
   
   DEBUG_MSG("Entering Text UI dispatcher loop");
   while(1) {
      UI_QUEUE_LOCK;

      if(!TAILQ_EMPTY(&ui_msg_queue)) {

         n = TAILQ_FIRST(&ui_msg_queue);
         TAILQ_REMOVE(&ui_msg_queue, n, link);

         text_msg(((struct ui_msg_elm*)n->ptr)->level, ((struct ui_msg_elm*)n->ptr)->msg); /* ooh */
         free(((struct ui_msg_elm*)n->ptr)->msg); /* aahh */
         free(n->ptr);
         free(n);

      }

      UI_QUEUE_UNLOCK;
      usleep(500);
   }
}
示例#2
0
void ContactView::sendChatMessage()
{
  auto msg = ui->chat_input->toPlainText();
  if (msg.size() != 0)
  {
    auto                               app = bts::application::instance();
    auto                               profile = app->get_profile();
    auto                               idents = profile->identities();
    bts::bitchat::private_text_message text_msg(msg.toUtf8().constData() );
    if (idents.size() )
    {
      fc::ecc::private_key my_priv_key = profile->get_keychain().get_identity_key(idents[0].dac_id_string);
      app->send_text_message(text_msg, _current_contact.public_key, my_priv_key);
      appendChatMessage("me", msg);
    }

    ui->chat_input->setPlainText(QString());
  }
}