MessagesSettingsPage::MessagesSettingsPage()
{
    chatMentionCheckBox.setChecked(settingsCache->getChatMention());
    connect(&chatMentionCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setChatMention(int)));

    chatMentionCompleterCheckbox.setChecked(settingsCache->getChatMentionCompleter());
    connect(&chatMentionCompleterCheckbox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setChatMentionCompleter(int)));
    
    ignoreUnregUsersMainChat.setChecked(settingsCache->getIgnoreUnregisteredUsers());
    ignoreUnregUserMessages.setChecked(settingsCache->getIgnoreUnregisteredUserMessages());
    connect(&ignoreUnregUsersMainChat, SIGNAL(stateChanged(int)), settingsCache, SLOT(setIgnoreUnregisteredUsers(int)));
    connect(&ignoreUnregUserMessages, SIGNAL(stateChanged(int)), settingsCache, SLOT(setIgnoreUnregisteredUserMessages(int)));
    
    invertMentionForeground.setChecked(settingsCache->getChatMentionForeground());
    connect(&invertMentionForeground, SIGNAL(stateChanged(int)), this, SLOT(updateTextColor(int)));

    invertHighlightForeground.setChecked(settingsCache->getChatHighlightForeground());
    connect(&invertHighlightForeground, SIGNAL(stateChanged(int)), this, SLOT(updateTextHighlightColor(int)));

    mentionColor = new QLineEdit();
    mentionColor->setText(settingsCache->getChatMentionColor());
    updateMentionPreview();
    connect(mentionColor, SIGNAL(textChanged(QString)), this, SLOT(updateColor(QString)));

    messagePopups.setChecked(settingsCache->getShowMessagePopup());
    connect(&messagePopups, SIGNAL(stateChanged(int)), settingsCache, SLOT(setShowMessagePopups(int)));

    mentionPopups.setChecked(settingsCache->getShowMentionPopup());
    connect(&mentionPopups, SIGNAL(stateChanged(int)), settingsCache, SLOT(setShowMentionPopups(int)));

    roomHistory.setChecked(settingsCache->getRoomHistory());
    connect(&roomHistory, SIGNAL(stateChanged(int)), settingsCache, SLOT(setRoomHistory(int)));

    customAlertString = new QLineEdit();
    customAlertString->setPlaceholderText("Word1 Word2 Word3");
    customAlertString->setText(settingsCache->getHighlightWords());
    connect(customAlertString, SIGNAL(textChanged(QString)), settingsCache, SLOT(setHighlightWords(QString)));

    QGridLayout *chatGrid = new QGridLayout;
    chatGrid->addWidget(&chatMentionCheckBox, 0, 0);
    chatGrid->addWidget(&invertMentionForeground, 0, 1);
    chatGrid->addWidget(mentionColor, 0, 2);
    chatGrid->addWidget(&chatMentionCompleterCheckbox, 1, 0);
    chatGrid->addWidget(&ignoreUnregUsersMainChat, 2, 0);
    chatGrid->addWidget(&hexLabel, 1, 2);
    chatGrid->addWidget(&ignoreUnregUserMessages, 3, 0);
    chatGrid->addWidget(&messagePopups, 4, 0);
    chatGrid->addWidget(&mentionPopups, 5, 0);
    chatGrid->addWidget(&roomHistory, 6, 0);
    chatGroupBox = new QGroupBox;
    chatGroupBox->setLayout(chatGrid);
    
    highlightColor = new QLineEdit();
    highlightColor->setText(settingsCache->getChatHighlightColor());
    updateHighlightPreview();
    connect(highlightColor, SIGNAL(textChanged(QString)), this, SLOT(updateHighlightColor(QString)));

    QGridLayout *highlightNotice = new QGridLayout;
    highlightNotice->addWidget(highlightColor, 0, 2);
    highlightNotice->addWidget(&invertHighlightForeground, 0, 1);
    highlightNotice->addWidget(&hexHighlightLabel, 1, 2);
    highlightNotice->addWidget(customAlertString, 0, 0);
    highlightNotice->addWidget(&customAlertStringLabel, 1, 0);
    highlightGroupBox = new QGroupBox;
    highlightGroupBox->setLayout(highlightNotice);

    messageList = new QListWidget;

    int count = settingsCache->messages().getCount();
    for (int i = 0; i < count; i++)
        messageList->addItem(settingsCache->messages().getMessageAt(i));
    
    aAdd = new QAction(this);
    aAdd->setIcon(QPixmap("theme:icons/increment"));
    connect(aAdd, SIGNAL(triggered()), this, SLOT(actAdd()));
    aRemove = new QAction(this);
    aRemove->setIcon(QPixmap("theme:icons/decrement"));
    connect(aRemove, SIGNAL(triggered()), this, SLOT(actRemove()));

    QToolBar *messageToolBar = new QToolBar;
    messageToolBar->setOrientation(Qt::Vertical);
    messageToolBar->addAction(aAdd);
    messageToolBar->addAction(aRemove);

    QHBoxLayout *messageListLayout = new QHBoxLayout;
    messageListLayout->addWidget(messageToolBar);
    messageListLayout->addWidget(messageList);

    messageShortcuts = new QGroupBox;
    messageShortcuts->setLayout(messageListLayout);

    QVBoxLayout *mainLayout = new QVBoxLayout;

    mainLayout->addWidget(messageShortcuts);
    mainLayout->addWidget(chatGroupBox);
    mainLayout->addWidget(highlightGroupBox);

    setLayout(mainLayout);
    
    retranslateUi();
}
Beispiel #2
0
void nsImapOfflineSync::ProcessCopyOperation(nsIMsgOfflineImapOperation *currentOp)
{
  nsTArray<nsMsgKey> matchingFlagKeys;
  PRUint32 currentKeyIndex = m_KeyIndex;
  nsCString copyDestination;
  currentOp->GetCopyDestination(0, getter_Copies(copyDestination));
  PRBool copyMatches = PR_TRUE;
  
  do { // loop for all messsages with the same destination
    if (copyMatches)
    {
      nsMsgKey curKey;
      currentOp->GetMessageKey(&curKey);
      matchingFlagKeys.AppendElement(curKey);
      currentOp->SetPlayingBack(PR_TRUE);
      m_currentOpsToClear.AppendObject(currentOp);
    }
    currentOp = nsnull;

    if (++currentKeyIndex < m_CurrentKeys.Length())
    {
      nsCString nextDestination;
      nsresult rv = m_currentDB->GetOfflineOpForKey(m_CurrentKeys[currentKeyIndex], PR_FALSE, &currentOp);
      copyMatches = PR_FALSE;
      if (NS_SUCCEEDED(rv) && currentOp)
      {
        nsOfflineImapOperationType opType; 
        currentOp->GetOperation(&opType);
        if (opType & nsIMsgOfflineImapOperation::kMsgCopy)
        {
          currentOp->GetCopyDestination(0, getter_Copies(nextDestination));
          copyMatches = copyDestination.Equals(nextDestination);
        }
      }
    }
  } 
  while (currentOp);

  nsCAutoString uids;
  nsCOMPtr<nsIMsgFolder> destFolder;
  GetExistingFolder(copyDestination, getter_AddRefs(destFolder));
  // if the dest folder doesn't really exist, these operations are
  // going to fail, so clear them out and move on.
  if (!destFolder)
  {
    NS_ERROR("trying to playing back copy to non-existent folder");
    ClearCurrentOps();
    ProcessNextOperation();
    return;
  }
  nsresult rv;
  nsCOMPtr<nsIMsgImapMailFolder> imapFolder = do_QueryInterface(m_currentFolder);
  if (imapFolder && DestFolderOnSameServer(destFolder))
  {
    rv = imapFolder->ReplayOfflineMoveCopy(matchingFlagKeys.Elements(), matchingFlagKeys.Length(), PR_FALSE, destFolder,
                   this, m_window);
  }
  else
  {
    nsCOMPtr<nsIMutableArray> messages(do_CreateInstance(NS_ARRAY_CONTRACTID, &rv));
    if (messages && NS_SUCCEEDED(rv))
    {
      for (PRUint32 keyIndex = 0; keyIndex < matchingFlagKeys.Length(); keyIndex++)
      {
        nsCOMPtr<nsIMsgDBHdr> mailHdr = nsnull;
        rv = m_currentFolder->GetMessageHeader(matchingFlagKeys.ElementAt(keyIndex), getter_AddRefs(mailHdr));
        if (NS_SUCCEEDED(rv) && mailHdr)
        {
          messages->AppendElement(mailHdr, PR_FALSE);
        }
      }
      nsCOMPtr<nsIMsgCopyService> copyService = do_GetService(NS_MSGCOPYSERVICE_CONTRACTID, &rv);
      if (copyService)
        copyService->CopyMessages(m_currentFolder, messages, destFolder, PR_FALSE, this, m_window, PR_FALSE);
    }
  }
}
Beispiel #3
0
int read (int expect_success)
{
  ACE_DEBUG((LM_DEBUG,
    ACE_TEXT("(%P|%t) read begins. \n")));

  try
  {
    ::Xyz::FooDataReader_var foo_dr
      = ::Xyz::FooDataReader::_narrow(datareader.in ());
    if (CORBA::is_nil (foo_dr.in ()))
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                 ACE_TEXT("(%P|%t) ::Xyz::FooDataReader::_narrow failed.\n")),
                 -1);
    }

    ::Xyz::FooDataReaderImpl* dr_servant =
      reference_to_servant< ::Xyz::FooDataReaderImpl> (foo_dr.in ());

    int num_reads = 0;
    int num_received = 0;

    bool init_val = false;
    ACE_Array<bool> messages(num_writes, init_val);

    while ( num_reads < num_writes)
    {

      ::Xyz::Foo foo;
      ::DDS::SampleInfo si ;

      DDS::ReturnCode_t status = dr_servant->read_next_sample(foo, si) ;
      num_reads ++;

      if (status == ::DDS::RETCODE_OK)
      {
        if (!expect_success)
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             ACE_TEXT("(%P|%t) ERROR: received a message but did not expect too!\n"))
                             , -1);

        }
        num_received++;

        if (default_key != foo.key)
        {
          ACE_ERROR ((LM_ERROR,
            ACE_TEXT("(%P|%t) ERROR: reader received incorrect key!\n")
                      ));
        }
        int msg_num = (int) foo.x;
        if ((0 <= msg_num) && (msg_num< num_writes))
        {
          messages[msg_num] = true;
        }
        else
        {
          ACE_ERROR ((LM_ERROR,
                      ACE_TEXT("(%P|%t) ERROR: reader received unexpected message number %d!\n"),
                      msg_num));
        }

        ACE_OS::fprintf(stderr, "foo.x = %f foo.y = %f, foo.key = %d\n",
                        foo.x, foo.y, foo.key);
      }
      else if (status == ::DDS::RETCODE_NO_DATA)
      {
        if (expect_success)
        {
          ACE_ERROR ((LM_ERROR,
            ACE_TEXT("(%P|%t) ERROR: read returned ::DDS::RETCODE_NO_DATA!\n")));
          ACE_OS::sleep(1);
        }
      }
      else
      {
        ACE_ERROR ((LM_ERROR,
          ACE_TEXT("(%P|%t) ERROR: read returned error %d\n"), status));
      }
    }

    int num_expected = num_writes;
    if (ignore_kind != DONT_IGNORE)
    {
       num_expected = 0;
    }

    if (num_received == num_expected)
    {
      for (int k = 0; k < num_expected; k ++)
      {
        if ( !messages[k] )
        {
          ACE_ERROR_RETURN ((LM_ERROR,
                             ACE_TEXT("(%P|%t) ERROR: reader did not receive message %d!\n"),
                             k), -1);
        }
      }
    }
    else
    {
       ACE_ERROR_RETURN ((LM_ERROR,
                          ACE_TEXT("(%P|%t) ERROR: reader received %d messages expected %d ")
                          ACE_TEXT("messages!\n"), num_received, num_expected),
                          -1);
    }
  }
  catch (...)
  {
    ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) Exception caught in read."), -1);
  }

  ACE_DEBUG((LM_DEBUG,
              ACE_TEXT("(%P|%t) read done.\n")));

  return 0;
}
Beispiel #4
0
static void dumpMessages()
{
    qWarning( "%s" , messages().join( "\n" ).ascii() );
}
Beispiel #5
0
void nsImapOfflineSync::ProcessMoveOperation(nsIMsgOfflineImapOperation *op)
{
  nsTArray<nsMsgKey> matchingFlagKeys;
  PRUint32 currentKeyIndex = m_KeyIndex;
  nsCString moveDestination;
  op->GetDestinationFolderURI(getter_Copies(moveDestination));
  PRBool moveMatches = PR_TRUE;
  nsCOMPtr <nsIMsgOfflineImapOperation> currentOp = op;
  do 
  {	// loop for all messsages with the same destination
    if (moveMatches)
    {
      nsMsgKey curKey;
      currentOp->GetMessageKey(&curKey);
      matchingFlagKeys.AppendElement(curKey);
      currentOp->SetPlayingBack(PR_TRUE);
      m_currentOpsToClear.AppendObject(currentOp);
    }
    currentOp = nsnull;
    
    if (++currentKeyIndex < m_CurrentKeys.Length())
    {
      nsCString nextDestination;
      nsresult rv = m_currentDB->GetOfflineOpForKey(m_CurrentKeys[currentKeyIndex], PR_FALSE, getter_AddRefs(currentOp));
      moveMatches = PR_FALSE;
      if (NS_SUCCEEDED(rv) && currentOp)
      {
        nsOfflineImapOperationType opType; 
        currentOp->GetOperation(&opType);
        if (opType & nsIMsgOfflineImapOperation::kMsgMoved)
        {
          currentOp->GetDestinationFolderURI(getter_Copies(nextDestination));
          moveMatches = moveDestination.Equals(nextDestination);
        }
      }
    }
  } 
  while (currentOp);
  
  nsCOMPtr<nsIMsgFolder> destFolder;
  GetExistingFolder(moveDestination, getter_AddRefs(destFolder));
  // if the dest folder doesn't really exist, these operations are
  // going to fail, so clear them out and move on.
  if (!destFolder)
  {
    NS_ERROR("trying to playing back move to non-existent folder");
    ClearCurrentOps();
    ProcessNextOperation();
    return;
  }
  nsCOMPtr<nsIMsgImapMailFolder> imapFolder = do_QueryInterface(m_currentFolder);
  if (imapFolder && DestFolderOnSameServer(destFolder))
  {
    imapFolder->ReplayOfflineMoveCopy(matchingFlagKeys.Elements(), matchingFlagKeys.Length(), PR_TRUE, destFolder,
      this, m_window);
  }
  else
  {
    nsresult rv;
    nsCOMPtr<nsIMutableArray> messages(do_CreateInstance(NS_ARRAY_CONTRACTID, &rv));
    if (NS_SUCCEEDED(rv))
    {
      for (PRUint32 keyIndex = 0; keyIndex < matchingFlagKeys.Length(); keyIndex++)
      {
        nsCOMPtr<nsIMsgDBHdr> mailHdr = nsnull;
        rv = m_currentFolder->GetMessageHeader(matchingFlagKeys.ElementAt(keyIndex), getter_AddRefs(mailHdr));
        if (NS_SUCCEEDED(rv) && mailHdr)
        {
          PRUint32 msgSize;
          // in case of a move, the header has already been deleted,
          // so we've really got a fake header. We need to get its flags and
          // size from the offline op to have any chance of doing the move.
          mailHdr->GetMessageSize(&msgSize);
          if (!msgSize)
          {
            imapMessageFlagsType newImapFlags;
            PRUint32 msgFlags = 0;
            op->GetMsgSize(&msgSize);
            op->GetNewFlags(&newImapFlags);
            // first three bits are the same
            msgFlags |= (newImapFlags & 0x07);
            if (newImapFlags & kImapMsgForwardedFlag)
              msgFlags |= nsMsgMessageFlags::Forwarded;
            mailHdr->SetFlags(msgFlags);
            mailHdr->SetMessageSize(msgSize);
          }
          messages->AppendElement(mailHdr, PR_FALSE);
        }
      }
      nsCOMPtr<nsIMsgCopyService> copyService = do_GetService(NS_MSGCOPYSERVICE_CONTRACTID, &rv);
      if (copyService)
        copyService->CopyMessages(m_currentFolder, messages, destFolder, PR_TRUE, this, m_window, PR_FALSE);
    }
  }
}
Beispiel #6
0
void help(int scr)
{
  int v,k;
  char s[200][100];
  strcpy (s[0],"COMMAND LINE");
  strcpy (s[1]," -p           : play");
  strcpy (s[2]," --nocolors   : B&W, for dummy terminals (telnet)");
  strcpy (s[3]," --autoscr    : autodetect the screen's size (BETA)");
  strcpy (s[4]," --fakelines  : draw lines on terminals without ACS");
  strcpy (s[5]," --new_start  : start with default configuration");
  strcpy (s[6],"");
  strcpy (s[7],"PLAYER");
  strcpy (s[8]," z            : previous");
  strcpy (s[9]," x            : play");
  strcpy (s[10]," c            : pause");
  strcpy (s[11]," v            : stop");
  strcpy (s[12]," b            : next");
  strcpy (s[13]," s            : Shuffle On/Off");
  strcpy (s[14]," <ENTER>      : Play ");
  strcpy (s[15]," <SPACE BAR>  : Set As Next ");
  strcpy (s[16]," <TAB>        : Add/Remove to/from filter ");
  strcpy (s[17]," f            : On/Off persistent filter ");
  strcpy (s[18]," F            : Clear filter ");
  strcpy (s[19]," <LEFT>       : Backward");
  strcpy (s[20]," <RIGHT>      : Forward");
  strcpy (s[21]," r            : Repreat current song ");
  strcpy (s[22]," i            : ID3v1.1 TAG Editor (for selected song)");
  strcpy (s[23]," I            : ID3v1.1 TAG Editor (for current song))");
  strcpy (s[24]," j or F3      : Jump to file");
  strcpy (s[25]," <INSERT>     : Volume + ");
  strcpy (s[26]," <DELETE>     : Volume - ");
  strcpy (s[27]," <HOME>       : PCM + ");
  strcpy (s[28]," <END>        : PCM - ");
  strcpy (s[29]," <            : Balance left ");
  strcpy (s[30]," >            : Balance right ");
  strcpy (s[31]," e            : Equalizer");
  strcpy (s[32]," '            : Repaint Desktop");
  strcpy (s[33]," *            : Increase desktop width");
  strcpy (s[34]," /            : Decrease desktop width");
  strcpy (s[35]," +            : Increase desktop height");
  strcpy (s[36]," -            : Decrease desktop height");
  strcpy (s[37]," t            : Switch clock display mode");
  strcpy (s[38]," \\            : Change Password");
  strcpy (s[39]," !            : Lock Display");
  strcpy (s[40]," =            : Switch Status Bar Format");
  strcpy (s[41]," h or F1      : Help");
  strcpy (s[42]," ?            : About and Statistics");
  strcpy (s[43]," {            : Set Alarm (\"Radio\") On");
  strcpy (s[44]," }            : Set Alarm (\"Radio\") Off");
  strcpy (s[45]," T            : Set Sleep mode");
  strcpy (s[46]," |            : On/Off Shut Down mode");
  strcpy (s[47]," o            : Settings");
  strcpy (s[48]," Q            : Quit");
  strcpy (s[49],"");
  strcpy (s[50],"PLAYLIST");
  strcpy (s[51]," a            : Add File");
  strcpy (s[52]," d            : Delete File");
  strcpy (s[53]," D            : Add Directory");
  strcpy (s[54]," R            : Delete All");
  strcpy (s[55]," S            : Sort Playlist");
  strcpy (s[56]," <UP>         : Cursor Up");
  strcpy (s[57]," <DOWN>       : Cursor Down");
  strcpy (s[58]," <PAGE UP>    : Page Up");
  strcpy (s[59]," <PAGE DOWN>  : Page Down");
  strcpy (s[60]," 0..9         : Fast Scroll");
  strcpy (s[61]," [            : Move Up");
  strcpy (s[62]," '            : Move Down");
  strcpy (s[63]," l            : Locate Current Song");
  strcpy (s[64]," L            : Autolocate Current Song");
  strcpy (s[65]," p            : Playlist Options");
  strcpy (s[66]," p,n          : New Playlist");
  strcpy (s[67]," p,l          : Load Playlist");
  strcpy (s[68]," p,s          : Save Playlist");
  strcpy (s[69]," p,i          : Import Playlist");
  strcpy (s[70]," p,e          : Export Playlist");
  strcpy (s[71]," E            : Edit playlist file entry");
  strcpy (s[72]," n            : Refresh list");
  strcpy (s[73]," ;            : On/Off save playlist position on exit");
  strcpy (s[74],"");
  strcpy (s[75],"JUMP TO FILE");
  strcpy (s[76]," <ENTER>      : Play");
  strcpy (s[77]," <SPACE BAR>  : Set as next");
  strcpy (s[78]," <TAB>        : Add/Remove to/from filter");
  strcpy (s[79]," F            : Add/Remove all songs to filter");
  strcpy (s[80]," i            : ID3 TAG Edditor");
  strcpy (s[81]," ESC or q     : Close window");
  strcpy (s[82],"");
  strcpy (s[83],"EQUALIZER WINDOW");
  strcpy (s[84]," <PAGE UP>    : Up ALL");
  strcpy (s[85]," <PAGE DOWN>  : Down ALL");
  strcpy (s[86]," a/z          : Up/Down Band #1");
  strcpy (s[87]," s/x          : Up/Down Band #2");
  strcpy (s[88]," d/c          : Up/Down Band #3");
  strcpy (s[89]," f/v          : Up/Down Band #4");
  strcpy (s[90]," g/b          : Up/Down Band #5");
  strcpy (s[91]," h/n          : Up/Down Band #6");
  strcpy (s[92]," j/m          : Up/Down Band #7");
  strcpy (s[93]," k/,          : Up/Down Band #8");
  strcpy (s[94]," l/.          : Up/Down Band #9");
  strcpy (s[95]," ;//          : Up/Down Band #10");
  strcpy (s[96]," r            : Set all bands to 0 (reset equalizer)");
  strcpy (s[97]," L            : Load Preset");
  strcpy (s[98]," S            : Save Preset");
  strcpy (s[99]," I            : Import Preset(s)");
  strcpy (s[100]," D            : Delete Preset(s)");
  strcpy (s[101]," A            : On/Off Automatic Equalizer");
  strcpy (s[102],"");
  strcpy (s[103],"STATISTICS");
  strcpy (s[104]," R            : Reset current session statistics");
  strcpy (s[105],"");
  strcpy (s[106],"SPECIAL FUNCTIONS");
  strcpy (s[107]," P            : Save playlist for MP3 CD Player");
  strcpy (s[108],"                * Save your playlist (p,s). Make a");
  strcpy (s[109],"                  new playlist (p,n).Load Directory (D)");
  strcpy (s[110],"                  from the CD in your playlist.");
  strcpy (s[111],"                * Tested on JazzPIPER MCD650S");
  strcpy (s[112],"");
  strcpy (s[113],"PLAYER MODES");
  strcpy (s[114]," Normal       : Next song in playlist (don\'t shuffle)");
  strcpy (s[115]," Shuffle      : Random next song (shuffle)");
  strcpy (s[116]," Next Song    : Next song is already selected");
  strcpy (s[117]," Filter       : There are files in the filter");
  strcpy (s[118]," P-Filter     : The filter is persistent");
  strcpy (s[119]," Password     : Display is locked with password");
  strcpy (s[120]," Radio        : Start/Stop music at a specific time");
  strcpy (s[121]," Sleep        : Shut Down at a specific time");
  strcpy (s[122]," Shut Down    : Shut Down after current song");
  WINDOW *w1;
  w1=newwin (scr+2,62,7,(nrcols-62)/2);
  wrefresh (w1);
  werase (w1);
  WINDOW *w;
  w=newwin (scr,60,8,(nrcols-60)/2);
  wsetcolor (w,12,0);
  for (int h=0;h<=scr+2;h++) mvwprintw (w,h,0,"                                                             ");
  wsetcolor (w,12,0);
  le_border (w,60,scr);
  wsetcolor (w,13,1);
  mvwprintw (w,0,1," Help ");
  wsetcolor (w,12,0);
  mvwprintw (w,scr-1,46," ESC - quit ");
  wrefresh(w);
  noecho();
  timeout (1);
  k=0;
  do
  {
    wsetcolor (w,12,0);
    for (int i=0;i<=scr-5;i++) 
    {
      mvwprintw (w,2+i,2,"                                                         ");
      mvwprintw (w,2+i,2,"%s",s[i+k]);
    }
    wsetcolor (w,12,0);
    mvwaddch (w,0,28,ACS_HLINE);
    mvwaddch (w,scr-1,28,ACS_HLINE);
    wsetcolor (w,12,1);
    if (k>0) mvwaddch (w,0,28,ACS_UARROW);
    if (k<93-(scr-5)) mvwaddch (w,scr-1,28,ACS_DARROW);
    wrefresh(w);
    do
    {
      messages();
      v=getch();
    } while (v==ERR);
    if (v == 27) 
    {
      v=getch();
      if (v==ERR) v='q';
      if (v==91)
      {
        v=getch();
	if (v==65) if (k > 0) k--;
        if (v==66) if (k < 122-(scr-5)) k++;
      }
    }
  }    
  while (v!='q');
  werase (w);
  reread=1;
}
Beispiel #7
0
void test_queue (void)
{
  std::cerr <<
    "************* QUEUES: Testing multithreaded queues*************\n";
  knowledge::KnowledgeBase knowledge;
  containers::Queue messages ("queue", knowledge, 7);
  madara::knowledge::KnowledgeRecord record;
  bool check;

  messages.enqueue ("first string");
  messages.enqueue ("second string");
  messages.enqueue ("third string");
  messages.enqueue ("fourth string");
  messages.enqueue ("fifth string");
  messages.enqueue ("sixth string");
  messages.enqueue ("seventh string");
  check = messages.enqueue ("eighth string");

  if (!check)
    std::cerr << "  SUCCESS: enqueue size check.\n";
  else
    std::cerr << "  FAIL: enqueue size check.\n";

  record = messages.dequeue ();
  if (record == "first string")
    std::cerr << "  SUCCESS: first dequeue.\n";
  else
    std::cerr << "  FAIL: first dequeue.\n";
  
  record = messages.dequeue ();
  if (record == "second string")
    std::cerr << "  SUCCESS: second dequeue.\n";
  else
    std::cerr << "  FAIL: second dequeue.\n";

  messages.enqueue ("eighth string");
  messages.enqueue ("ninth string");
  check = messages.enqueue ("tenth string");
  
  if (!check)
    std::cerr << "  SUCCESS: 2nd enqueue size check.\n";
  else
    std::cerr << "  FAIL: 2nd enqueue size check.\n";

  record = messages.dequeue ();
  if (record == "third string")
    std::cerr << "  SUCCESS: third dequeue.\n";
  else
    std::cerr << "  FAIL: third dequeue.\n";
  
  record = messages.dequeue ();
  if (record == "fourth string")
    std::cerr << "  SUCCESS: fourth dequeue.\n";
  else
    std::cerr << "  FAIL: fourth dequeue.\n";
  
  record = messages.dequeue ();
  if (record == "fifth string")
    std::cerr << "  SUCCESS: fifth dequeue.\n";
  else
    std::cerr << "  FAIL: fifth dequeue.\n";
  
  record = messages.dequeue ();
  if (record == "sixth string")
    std::cerr << "  SUCCESS: sixth dequeue.\n";
  else
    std::cerr << "  FAIL: sixth dequeue.\n";
  
  record = messages.dequeue ();
  if (record == "seventh string")
    std::cerr << "  SUCCESS: seventh dequeue.\n";
  else
    std::cerr << "  FAIL: seventh dequeue.\n";
  
  record = messages.dequeue ();
  if (record == "eighth string")
    std::cerr << "  SUCCESS: eighth dequeue.\n";
  else
    std::cerr << "  FAIL: eighth dequeue.\n";
  
  record = messages.dequeue ();
  if (record == "ninth string")
    std::cerr << "  SUCCESS: ninth dequeue.\n";
  else
    std::cerr << "  FAIL: ninth dequeue.\n";
  
  messages.enqueue ("first cleared");
  messages.enqueue ("second cleared");

  if (messages.inspect (0) == "first cleared" &&
      messages.inspect (1) == "second cleared")
  {
    std::cerr << "  SUCCESS: inspect on multiple records.\n";
  }
  else
  {
    std::cerr << "  FAIL: inspect on multiple records.\n";
  }

  messages.clear ();

  if (messages.count () == 0 && messages.size () == 7)
    std::cerr << "  SUCCESS: clear.\n";
  else
    std::cerr << "  FAIL: clear.\n";
  
  
  if (!messages.dequeue (false).is_valid ())
  {
    std::cerr << "  SUCCESS: asynchronous dequeue empty.\n";
  }
  else
  {
    std::cerr << "  FAIL: asynchronous dequeue empty.\n";
  }

  messages.enqueue ("first string");
  messages.enqueue ("second string");
  messages.enqueue ("third string");
  messages.enqueue ("fourth string");
  messages.enqueue ("fifth string");
  messages.enqueue ("sixth string");
  messages.enqueue ("seventh string");

  messages.resize (5);

  if (messages.count () == 5 && 
    messages.count () == messages.size ())
  {
    std::cerr << "  SUCCESS: resize.\n";
  }
  else
  {
    std::cerr << "  FAIL: resize.\n";
  }

  knowledge.print ();
}
Beispiel #8
0
void about(int scr)
{
/*    initscr();
    WINDOW *w;
    w=newwin (16,78,7,1);
    werase(w);
    setcolor (1,1);
    mvprintw (7,34,"LinuxEyes");
    setcolor (1,1);
    mvprintw (9,2,"AUTHOR");
    mvprintw (13,2,"COPYRIGHT");
    mvprintw (17,2,"LOTS OF THANKS TO");
    mvprintw (20,2,"BUGS AND SUGGESTIONS");
    setcolor (1,0);
    mvprintw (10,5,"Alexandru Radovici - [email protected]");
    mvprintw (11,5,"                     [email protected]");
    mvprintw (14,5,"This program is free. You may use it on your own risk. You may distribute");
    mvprintw (15,2,"it only integral.");
    mvprintw (18,5,"Xaudio - http://www.xaudio.com"); 
    mvprintw (21,5,"If you have found bugs or have some suggestions to make please send me an");
    mvprintw (22,2,"e-mail. Thank you.");
    wrefresh (w); */
  int v,k;
  char s[100][100];
  strcpy (s[0],"AUTHOR");
  strcpy (s[1],"    Alexandru Radovici - [email protected]");
  strcpy (s[2],"");
  strcpy (s[3],"VERSION");
  strcpy (s[4],"    LinuxEyes 0.8, build 0.8.6 (February 8, 2003)");
  strcpy (s[5],"");
  strcpy (s[6],"ROMANIAN SOFTWARE");
  strcpy (s[7],"    This software was made in Romania!");
  strcpy (s[8],"");
  strcpy (s[9],"WEBSITE");
  strcpy (s[10],"    http://lug.orizont.net/~linuxeyes");
  strcpy (s[11],"");
  strcpy (s[12],"COPYRIGHT & DISTRIBUTION");
  strcpy (s[13],"    This software is freeware, you may use it on your");
  strcpy (s[14],"own risk. You may distribute it only integral.");
  strcpy (s[15],"");
  strcpy (s[16],"MPEG Audio Layer 3");
  strcpy (s[17],"    Xaudio - http://www.xaudio.com");
  strcpy (s[18],"");
  strcpy (s[19],"BUGS & SUGGESTIONS");
  strcpy (s[20],"    If you find any bugs or have any suggestion please");
  strcpy (s[21],"email me. ([email protected]) Thank you!");
  strcpy (s[22],"");
  strcpy (s[23],"LOTS OF THANKS TO");
  strcpy (s[24],"    Vera and Iuliu Radovici");
  strcpy (s[25],"    Ovidiu Stoica - [email protected]");
  strcpy (s[26],"    Alexandru Armean - [email protected]");
  strcpy (s[27],"    Valeriu Moldovan - [email protected]");
  strcpy (s[28],"    Cristian Klein - [email protected]");
  strcpy (s[29],"");
  strcpy (s[30],"CURRENT SESSION STATISTICS");
  sprintf (s[31],"    Songs Played: %d",(int)n_songs);
  sprintf (s[32],"    Time Played: %d:%.2d:%.2d",(int)n_secs/(60*60),(int)(n_secs/60)%60,(int)n_secs%60);
  strcpy (s[33],"");
  strcpy (s[34],"GLOBAL STATISTICS");
  sprintf (s[35],"    Songs Played: %d",(int)songs);
  sprintf (s[36],"    Time Played: %d:%.2d:%.2d",(int)secs/(60*60),(int)(secs/60)%60,(int)secs%60);
  WINDOW *w1;
  w1=newwin (scr+2,62,7,(nrcols-62)/2);
  wrefresh (w1);
  werase (w1);
  WINDOW *w;
  w=newwin (scr,60,8,(nrcols-60)/2);
  wsetcolor (w,12,0);
  for (int h=0;h<=scr+2;h++) mvwprintw (w,h,0,"                                                            ");
  wsetcolor (w,12,0);
  le_border (w,60,scr);
  wsetcolor (w,13,1);
  mvwprintw (w,0,1," About LinuxEyes ");
  wsetcolor (w,12,0);
  mvwprintw (w,scr-1,46," ESC - quit ");
  wrefresh(w);
  noecho();
  timeout (1);
  k=0;
  do
  {
    wsetcolor (w,12,0);
    for (int i=0;i<=scr-5;i++) 
    {
      mvwprintw (w,2+i,2,"                                                         ");
      mvwprintw (w,2+i,2,"%s",s[i+k]);
    }
    wsetcolor (w,12,0);
    mvwaddch (w,0,28,ACS_HLINE);
    mvwaddch (w,scr-1,28,ACS_HLINE);
    wsetcolor (w,12,1);
    if (k>0) mvwaddch (w,0,28,ACS_UARROW);
    if (k<35-(scr-5)) mvwaddch (w,scr-1,28,ACS_DARROW);
    wrefresh(w);
    do
    {
      sprintf (s[31],"    Songs Played: %d",(int)n_songs);
      sprintf (s[32],"    Time Played: %d:%.2d:%.2d",(int)n_secs/(60*60),(int)(n_secs/60)%60,(int)n_secs%60);
      sprintf (s[35],"    Songs Played: %d",(int)songs);
      sprintf (s[36],"    Time Played: %d:%.2d:%.2d",(int)secs/(60*60),(int)(secs/60)%60,(int)secs%60);
      for (int i=0;i<=scr-5;i++) if (((i+k)==30) || ((i+k)==31) || ((i+k)==34) || ((i+k)==35))
      {
        wsetcolor (w,12,0);
        mvwprintw (w,2+i,2,"                                                         ");
        mvwprintw (w,2+i,2,"%s",s[i+k]);
	wrefresh (w);
      }
      messages();
      v=getch();
    } while (v==ERR);
    if (v == 27) 
    {
      v=getch();
      if (v==ERR) v='q';
      if (v==91)
      {
        v=getch();
	if (v==65) if (k > 0) k--;
        if (v==66) if (k < 36-(scr-5)) k++;
      }
    }
    if (v=='R')
    {
      n_songs=0;
      n_secs=0;
    }
  }    
  while (v!='q');
  werase (w);
  reread=1;
}
int main()
{

    //Remove shared memory on construction and destruction
    struct shm_remove
    {
      shm_remove() { bip::shared_memory_object::remove("ipdf_testdomain_simpletest"); }
      ~shm_remove(){ bip::shared_memory_object::remove("ipdf_testdomain_simpletest"); }
    } remover;

    // create segment and corresponding allocator
    bip::managed_shared_memory segment(bip::open_or_create, "ipdf_testdomain_simpletest", 65536);
    ipdf::ShmPortCondition *port = segment.find_or_construct<ipdf::ShmPortCondition>("port_testing")();

    shm::shmem_channel_allocator alloc(segment.get_segment_manager());
    shm::channel_message_queue *queue1 = segment.find_or_construct<shm::channel_message_queue>("queue1")();
    shm::channel_message_queue *queue2 = segment.find_or_construct<shm::channel_message_queue>("queue2")();


    bool running = true;

    unsigned int total_message_count = 0;

    while (running)
    {
        bool process_queues = false;
        // wait for activity .. could also be polling ...
        {
            bip::scoped_lock<bip::interprocess_mutex> lock(port->port_mutex);
            if (!port->data_available) {
                boost::posix_time::ptime timeout = boost::get_system_time() + boost::posix_time::milliseconds(1);
                bool was_notified = port->port_condition.timed_wait(lock, timeout);
                if (was_notified) {
                    process_queues = true;
                }
                port->data_available = false;
            }
        }

        std::vector<unsigned long long> messages(0);

        if (process_queues) {
            std::cout << "process_queues" << "\n";
            bool continue_poll = true;
            shm::ChannelMessage v(alloc);
            // loop until no more values are available
            while (continue_poll) {
                continue_poll = false;
                if (queue1->pop(v)) {
                    //std::cout << "Processed 1: '" << v.timestamp << "'\n";
                    messages.push_back(v.timestamp);
                    continue_poll = true;
                }
                if (queue2->pop(v)) {
//                    std::cout << "Processed 2: '" << v.timestamp << "'\n";
                    messages.push_back(v.timestamp);
                    continue_poll = true;
                }
            }
        }

        if (messages.size() > 0) {
            total_message_count += messages.size();
            std::cout << " received " << total_message_count << " messages in total \n";
        }
    }
}
Beispiel #10
0
QVariant
EnabledLocalesModel::data( const QModelIndex& index, int role ) const
{
    if ( index.row() < 0 || index.row() >= m_locales.count() )
        return QVariant();
    const QString& localeCode = m_locales[index.row()];

    Locale locale( localeCode.toLatin1() );

    // Get language and country in current system locale
    UnicodeString uDisplayLanguage;
    UnicodeString uDisplayCountry;
    locale.getDisplayLanguage( locale, uDisplayLanguage );
    locale.getDisplayCountry( locale, uDisplayCountry );

    // Capitalize language and country
    UErrorCode status;
    BreakIterator* titleIterator = BreakIterator::createTitleInstance( locale, status );
    uDisplayLanguage = uDisplayLanguage.toTitle( titleIterator );
    uDisplayCountry = uDisplayCountry.toTitle( titleIterator );

    QString displayLanguage = unicodeStringToQString( uDisplayLanguage );
    QString displayCountry = unicodeStringToQString( uDisplayCountry );

    switch ( role )
    {
    case Qt::DisplayRole:
        return QString( "%1 - %2 (%3)" ).arg( displayLanguage ).arg( displayCountry ).arg( localeCode );
    case LocaleCodeRole:
        return localeCode;
    case CountryRole:
        return displayCountry;
    case LanguageRole:
        return displayLanguage;
    case AddressRole:
        return address();
    case CollateRole:
        return collate();
    case CtypeRole:
        return ctype();
    case IdentificationRole:
        return identification();
    case LangRole:
        return lang();
    case LanguageLcRole:
        return language();
    case MeasurementRole:
        return measurement();
    case MonetaryRole:
        return monetary();
    case MessagesRole:
        return messages();
    case NameRole:
        return name();
    case NumericRole:
        return numeric();
    case PaperRole:
        return paper();
    case TelephoneRole:
        return telephone();
    case TimeRole:
        return time();
    }

    return QVariant();
}
		void ForumInterfacePage::DisplayTopic(
			std::ostream& stream,
			const cms::Webpage& page,
			boost::shared_ptr<const cms::Webpage> dateDisplayPage,
			const server::Request& request,
			const ForumTopic& topic,
			std::size_t rank
		){
			ParametersMap pm(request.getFunction()->getTemplateParameters());

			Env env;
			ForumMessageTableSync::SearchResult messages(
				ForumMessageTableSync::Search(
					env,
					topic.getKey(),
					optional<string>(),
					optional<RegistryKeyType>(),
					true,
					0,
					optional<size_t>(),
					true,
					false
			)	);
			pm.insert(DATA_MESSAGES_NUMBER, messages.size());

			pm.insert(Request::PARAMETER_OBJECT_ID, topic.getKey());
			pm.insert(DATA_NAME, topic.getName());
			if(dateDisplayPage.get())
			{
				stringstream content;
				DateTimeInterfacePage::Display(content, dateDisplayPage, request, topic.getDate());
				pm.insert(DATA_DATE, content.str());
			}
			else
			{
				pm.insert(DATA_DATE, lexical_cast<string>(topic.getDate()));
			}

			if(!messages.empty())
			{
				boost::shared_ptr<ForumMessage> message(messages.front());

				if(dateDisplayPage.get())
				{
					stringstream content;
					DateTimeInterfacePage::Display(content, dateDisplayPage, request, message->getDate());
					pm.insert(DATA_LAST_MESSAGE_DATE, content.str());
				}
				else
				{
					pm.insert(DATA_LAST_MESSAGE_DATE, lexical_cast<string>(message->getDate()));
				}
			}

			pm.insert(DATA_CLOSED, topic.getClosed());

			if(topic.getUser())
			{
				pm.insert(DATA_USER_ID, topic.getUser()->getKey());
				pm.insert(DATA_USER_EMAIL, topic.getUser()->getEMail());
				pm.insert(DATA_USER_NAME, topic.getUser()->getName());
				pm.insert(DATA_USER_SURNAME, topic.getUser()->getSurname());
			}
			else
			{
				pm.insert(DATA_USER_NAME, topic.getUserName());
				pm.insert(DATA_USER_EMAIL, topic.getUserEMail());
			}

			pm.insert(DATA_RANK, rank);
			pm.insert(DATA_RANK_IS_ODD, rank % 2);

			page.display(stream, request, pm);
		}
OSL_SHADEOP int
osl_getmessage (ShaderGlobals *sg, const char *source_, const char *name_,
                long long type_, void *val, int derivs,
                int layeridx, const char* sourcefile_, int sourceline)
{
    const ustring &source (USTR(source_));
    const ustring &name (USTR(name_));
    const ustring &sourcefile (USTR(sourcefile_));

    // recreate TypeDesc -- we just crammed it into an int!
    TypeDesc type (*(TypeDesc *)&type_);
    bool is_closure = (type.basetype == TypeDesc::UNKNOWN); // secret code for closure
    if (is_closure)
        type.basetype = TypeDesc::PTR;  // for closures, we store a pointer

    static ustring ktrace ("trace");
    if (source == ktrace) {
        // Source types where we need to ask the renderer
        RendererServices *renderer = sg->context->renderer();
        return renderer->getmessage (sg, source, name, type, val, derivs);
    }

    MessageList &messages (sg->context->messages());
    const Message* m = messages.find(name);
    if (m != NULL) {
        if (m->name == name) {
            if (m->type != type) {
                // found message, but types don't match
                sg->context->error(
                    "type mismatch for message \"%s\" (%s as %s here: %s:%d)"
                    " cannot fetch as %s from %s:%d",
                    name.c_str(),
                    m->has_data() ? "created" : "queried",
                    m->type == TypeDesc::PTR ? "closure color" : m->type.c_str(),
                    m->sourcefile.c_str(),
                    m->sourceline,
                    is_closure ? "closure color" : type.c_str(),
                    sourcefile.c_str(),
                    sourceline);
                return 0;
            }
            if (!m->has_data()) {
                // getmessage ran before and found nothing - just return 0
                return 0;
            }
            if (m->layeridx > layeridx) {
                // found message, but was set by a layer deeper than the one querying the message
                sg->context->error(
                    "message \"%s\" was set by layer #%d (%s:%d)"
                    " but is being queried by layer #%d (%s:%d)"
                    " - messages may only be transfered from nodes "
                    "that appear earlier in the shading network",
                    name.c_str(),
                    m->layeridx,
                    m->sourcefile.c_str(),
                    m->sourceline,
                    layeridx,
                    sourcefile.c_str(),
                    sourceline);
                return 0;
            }
            // Message found!
            size_t size = type.size();
            memcpy (val, m->data, size);
            if (derivs) // TODO: move this to llvm code gen?
                memset (((char *)val)+size, 0, 2*size);
            return 1;
        }
    }
    // Message not found -- we must record this event in case another layer tries to set the message again later on
    if (sg->context->shadingsys().strict_messages())
        messages.add(name, NULL, type, layeridx, sourcefile, sourceline);
    return 0;
}