bool XmppServerArchive::handleStanza(const QDomElement &element)
{
    const QString domain = server()->domain();
    const QString from = element.attribute("from");
    const QString to = element.attribute("to");

    if (element.tagName() == "message" &&
        to != domain &&
        (QXmppUtils::jidToDomain(from) == domain || QXmppUtils::jidToDomain(to) == domain) &&
        element.attribute("type") != "error" &&
        element.attribute("type") != "groupchat" &&
        element.attribute("type") != "headline" &&
        !element.firstChildElement("body").text().isEmpty())
    {
        const QDateTime now = QDateTime::currentDateTime().toUTC();
        QXmppMessage message;
        message.parse(element);

        if (QXmppUtils::jidToDomain(from) == domain)
            saveMessage(message, now, false);

        if (QXmppUtils::jidToDomain(to) == domain) {
            saveMessage(message, now, true);

            // offline messages
            bool found = false;

            XmppServerPresence *presenceExtension = XmppServerPresence::instance(server());
            Q_ASSERT(presenceExtension);
            foreach (const QXmppPresence &presence, presenceExtension->availablePresences(QXmppUtils::jidToBareJid(to))) {
                if (QXmppUtils::jidToResource(to).isEmpty() || presence.from() == to) {
                    found = true;
                    break;
                }
            }
            if (!found) {
                message.setStamp(now);
                message.setState(QXmppMessage::None);
                message.setTo(QXmppUtils::jidToBareJid(to));

                QBuffer buffer;
                buffer.open(QIODevice::WriteOnly);
                QXmlStreamWriter writer(&buffer);
                message.toXml(&writer);

                OfflineMessage offline;
                offline.setData(QString::fromUtf8(buffer.data()));
                offline.setJid(QXmppUtils::jidToBareJid(to));
                offline.setStamp(now);
                offline.save();
                return true;
            }
        }

        return false;

    } else if (element.tagName() == "presence" &&
// Child windows functions
void MainWindow::createChildWindows()
{
	currentRecipient = ALL_FRIENDS_ID;

	// Creating drawing window
	drawingWindow = new DrawingWindow(this);

	connect(drawingWindow, SIGNAL(clipartWindowRequest()), this, SLOT(onShowClipart()));
	connect(drawingWindow, SIGNAL(messageSent()), this, SLOT(onMessageSent()));
	connect(drawingWindow, SIGNAL(replyChanged()), tvWidget, SLOT(replyChanged()));
	
	drawingWindow->updatePosition(this);

	historyWindow = new HistoryWindow(this);
	historyWindow->setTvWidget(tvWidget);

	connect(historyWindow, SIGNAL(beginOfPreview(const MessageKey &)), tvWidget, SLOT(showHistoryMessage(const MessageKey &)));
	connect(historyWindow, SIGNAL(endOfPreview()), tvWidget, SLOT(stopShowingHistory()));
	connect(historyWindow, SIGNAL(clicked(const MessageKey &)), tvWidget, SLOT(scrollToMessage(const MessageKey &)));
	connect(historyWindow, SIGNAL(deleteMessages(const QList<MessageKey> &)), tvWidget, SLOT(deleteMessages(const QList<MessageKey> &)));
	connect(historyWindow, SIGNAL(saveMessage()), tvWidget, SLOT(saveMessage()));
	connect(historyWindow, SIGNAL(copyMessage()), tvWidget, SLOT(copyMessage()));

	connect(tvWidget, SIGNAL(publishRequest(const MessageKey &)), historyWindow, SLOT(publishMessage(const MessageKey &)));

	historyWindow->updatePosition(this);

	contactList = new NewContactListWindow(this);
	contactList->updatePosition(this);
	contactList->initAutoUpdater(&autoUpdater);
	
	// Connect menu signals
	connect(contactList, SIGNAL(goOnline()), this, SLOT(relogon()));
	connect(contactList, SIGNAL(goOffline()), this, SLOT(offline()));
	connect(contactList, SIGNAL(goLogout()), this, SLOT(logout()));
	connect(contactList, SIGNAL(goExit()), this, SLOT(shutDown()));
	connect(contactList, SIGNAL(contactSelected(qint32)), this, SLOT(onContactSelected(qint32)));
	connect(contactList, SIGNAL(contactImageDrop(qint32, const QImage &)), this, SLOT(onContactImageDrop(qint32, const QImage &)));
	connect(contactList, SIGNAL(soundStateChanged(const bool)), this, SLOT(onSoundStateChanged(const bool)));
	connect(contactList, SIGNAL(unreadContacts(int)), contactListButton, SLOT(update(int)));
#ifdef Q_WS_MAC
    connect(contactList, SIGNAL(unreadContacts(int)), DockIconHandler::instance(), SLOT(unreadCountChanged(int)));
#endif
	connect(contactList, SIGNAL(historyCleared()), tvWidget, SLOT(reload()));

	connect(welcomeWidget, SIGNAL(showProfileDialog()), contactList, SLOT(onShowProfileDialog()));
	connect(welcomeWidget, SIGNAL(showFindFriendsDialog()), contactList, SLOT(onShowFindDialog()));
}
Beispiel #3
0
void AnswerMachineDialog::onNoAudio()
{
  switch(status){
    
  case 0: {
    // announcement mode - no recording
    if (MODE_ANN == vm_mode) {
      dlg->bye();
      setStopped();
      return;
    }
    
    playlist.addToPlaylist(new AmPlaylistItem(NULL,&a_msg));
    
    setTimer(RECORD_TIMER, AnswerMachineFactory::MaxRecordTime);
    
    status = 1;
  } break;

  case 1:
    a_beep.rewind();
    playlist.addToPlaylist(new AmPlaylistItem(&a_beep,NULL));
    status = 2;
    break;
    
  case 2:
    dlg->bye();
    saveMessage();
    setStopped();
    break;
    
  }
}
Beispiel #4
0
void saveMessageList(ofstream &output, const tMessageList &list) {

	output << list.counter << endl;

	for (int n = 0; n < list.counter; n++) {
		saveMessage(output, list.msgList[n]);
	}
}
Beispiel #5
0
void AnswerMachineDialog::onBye(const AmSipRequest& req)
{
  dlg->reply(req,200,"OK");

  setInOut(NULL, NULL);
  saveMessage();
  setStopped();
}
Beispiel #6
0
bool MessageDevice::setPartData(int partIndex, const QByteArray &data)
{
  if (partIndex < _index->getPartCount() &&
      partIndex >= 0 &&
      !data.isEmpty()) {
    return saveMessage(partIndex, data);
  }

  return false;
}
Beispiel #7
0
bool MessageDevice::deletePart(int partIndex)
{
  if (_index->removePart(partIndex)) {
    _index->setMultipartOnly(true);

    QByteArray data;
    saveMessage(-1, data);

    //ServerNotifier::thisInstance()->objectDeleted(_index->getParentFolder()->name()+"/"+_index->getID()+ATTR_SEP+QString::number(partIndex));
    //ServerNotifier::thisInstance()->objectChanged(_index->getParentFolder()->name()+"/"+_index->getID());

    return true;
  } else {
    return false;
  }
}
void VideoRecordDialog::screenshot(RenderDevice* rd) {
    const shared_ptr<Texture>& texture = Texture::createEmpty("Screenshot", rd->width(), rd->height(), ImageFormat::RGB8());

    texture->copyFromScreen(rd->viewport());
    texture->visualization = Texture::Visualization::sRGB();

    String filename = ScreenshotDialog::nextFilenameBase(m_filenamePrefix) + "." + toLower(m_ssFormatList[m_ssFormatIndex]);
    const shared_ptr<Image>& image = texture->toImage();
    if (rd->invertY()) {
        image->flipVertical();
    }

    if (ScreenshotDialog::create(window(), theme(), FilePath::parent(filename))->getFilename(filename, "Save Screenshot", texture)) {
        filename = trimWhitespace(filename);

        if (! filename.empty()) {
            image->save(filename);
            saveMessage(filename);
        }
    }
}
void VideoRecordDialog::stopRecording() {
    debugAssert(m_video);

    // Save the movie
    m_video->commit();
    String oldFilename = m_video->filename();
    String newFilename = oldFilename;
    m_video.reset();

    if (ScreenshotDialog::create(window(), theme(), FilePath::parent(newFilename))->getFilename(newFilename, "Save Movie")) {
        newFilename = trimWhitespace(newFilename);

        if (newFilename.empty()) {
            // Cancelled--delete the file
            FileSystem::removeFile(oldFilename);
        } else {
            if (oldFilename != newFilename) {
                FileSystem::rename(oldFilename, newFilename);
            }
            saveMessage(newFilename);
        }
    }

    if (m_app) {
        // Restore the app state
        m_app->setFrameDuration(m_oldRealTimeTargetDuration, m_oldSimTimeStep);
    }

    // Reset the GUI
    m_recordButton->setCaption("Record Now (" + m_hotKeyString + ")");

    // Restore the window caption as well
    OSWindow* window = const_cast<OSWindow*>(OSWindow::current());
    const String& c = window->caption();
    const String& appendix = " - Recording " + m_hotKeyString + " to stop";
    if (endsWith(c, appendix)) {
        window->setCaption(c.substr(0, c.size() - appendix.size()));
    }
}
Beispiel #10
0
int dMessageEditor::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: clickedSendButton(); break;
        case 1: splitterMoved(*(int*)_a[1],*(int*)_a[2]); break;
        case 2: textBold(); break;
        case 3: textUnderline(); break;
        case 4: textItalic(); break;
        case 5: textAlign(*(QAction**)_a[1]); break;
        case 6: textFamily(*(QString*)_a[1]); break;
        case 7: textSize(*(QString*)_a[1]); break;
        case 8: textColor(); break;
        case 9: saveMessage(); break;
        }
        _id -= 10;
    }
    return _id;
}
Beispiel #11
0
LogVoiceMail::LogVoiceMail
(
	QWidget* parent,
	const char* name
) : TAAWidget(parent)
{
    setCaption( "Voice Mail Logging" );

    // Create the widgets
    QLabel *dateLabel = new QLabel(this);
    dateLabel->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
    dateLabel->setText("D&ate/Time:");

    msgDateTime = new Q3DateTimeEdit(QDateTime::currentDateTime(), this, "MsgDateTime");
    dateLabel->setBuddy(msgDateTime);
    
    QLabel *messageLabel = new QLabel(this);
    messageLabel->setAlignment(Qt::AlignRight|Qt::AlignTop);
    messageLabel->setText("M&essage:");

    message = new Q3MultiLineEdit(this);
    message->setWordWrap(Q3MultiLineEdit::WidgetWidth);
    messageLabel->setBuddy(message);

    saveButton = new QPushButton(this);
    saveButton->setText("&Save");
    connect(saveButton, SIGNAL(clicked()), this, SLOT(saveMessage()));

    closeButton = new QPushButton(this);
    closeButton->setText("&Close");
    connect(closeButton, SIGNAL(clicked()), this, SLOT(closeClicked()));

    statusLabel = new QLabel(this);
    statusLabel->setAlignment(Qt::AlignLeft|Qt::AlignVCenter);
    statusLabel->setFrameStyle(Q3Frame::Panel|Q3Frame::Sunken);
    statusLabel->setMinimumSize(0, 20);

    // Now, create our layouts
    // Date/time area.
    Q3GridLayout *dtl = new Q3GridLayout(2, 4, 3);
    dtl->setColStretch(0, 0);
    dtl->setColStretch(1, 1);
    dtl->setColStretch(2, 0);
    dtl->setColStretch(3, 1);
    dtl->setRowStretch(0, 0);
    dtl->setRowStretch(1, 1);

    dtl->addWidget(dateLabel,               0, 0);
    dtl->addMultiCellWidget(msgDateTime,    0, 0, 1, 3);
    dtl->addWidget(messageLabel,            1, 0);
    dtl->addMultiCellWidget(message,        1, 1, 1, 3);

    // The action button layout.
    Q3BoxLayout *abl = new Q3BoxLayout(Q3BoxLayout::LeftToRight, 5);
    abl->addStretch(1);
    abl->addWidget(saveButton, 0);
    abl->addWidget(closeButton, 0);
    abl->addSpacing(5);

    // The main layout.
    Q3BoxLayout *ml = new Q3BoxLayout(this, Q3BoxLayout::TopToBottom, 0, 0);
    ml->addSpacing(3);
    ml->addLayout(dtl, 1);
    ml->addSpacing(3);
    ml->addLayout(abl, 0);
    ml->addSpacing(3);
    ml->addWidget(statusLabel, 0);

    // Done.

    msgDateTime->setFocus();

    resize(350, 180);
}
Beispiel #12
0
Composer::Composer( QWidget *parent )
: QWidget( parent )
{
	QGridLayout * layout = new QGridLayout( this, 1, 1, 6 );

	uint line = 0;
	
	layout->addWidget( new QLabel( tr( "SMTP:" ), this ), line, 0 );
	smtp_server = new QLineEdit( this );
	//smtp_server->setText("10.10.11.7"); 
	smtp_server->setText("10.10.11.7");
	layout->addWidget( smtp_server, line, 1 );
	line++;

	layout->addWidget( new QLabel( tr( "From:" ), this ), line, 0 );
	from = new QLineEdit( this );
	from->setText("Lukasz Iwaszkiewicz <*****@*****.**>");
	layout->addWidget( from, line, 1 );
	line++;

	layout->addWidget( new QLabel( tr( "To:" ), this ), line, 0 );
	to = new QLineEdit( this );
	//to->setText("[email protected], [email protected]");
	to->setText("*****@*****.**");
	layout->addWidget( to, line, 1 );
	line++;
	
	layout->addWidget( new QLabel( tr( "Cc:" ), this ), line, 0 );
	cc = new QLineEdit( this );
	//cc->setText("*****@*****.**");
	cc->setText("");
	layout->addWidget( cc, line, 1 );
	line++;
	
	layout->addWidget( new QLabel( tr( "Bcc:" ), this ), line, 0 );
	bcc = new QLineEdit( this );
	//bcc->setText("*****@*****.**");
	bcc->setText("");
	layout->addWidget( bcc, line, 1 );
	line++;

	layout->addWidget( new QLabel( tr( "Encoding" ), this ), line, 0 );
	enc = new QLineEdit( this );
	//bcc->setText("*****@*****.**");
	enc->setText("ISO-8859-2");
	layout->addWidget( enc, line, 1 );
	line++;

	layout->addWidget( new QLabel( tr( "Subject:" ), this ), line, 0 );
	subject = new QLineEdit( this );
	//subject->setText("test");
	subject->setText(tr("test"));
	layout->addWidget( subject, line, 1 );
	line++;

	layout->addWidget( new QLabel( tr( "Send as HTML:" ), this ), line, 0 );
	html = new QCheckBox( this );
	layout->addWidget( html , line, 1 );
	line++;

	bold = new QPushButton( tr( "Bold" ), this );
	layout->addWidget( bold, line, 0 );
	connect( bold, SIGNAL( clicked() ), this, SLOT( setBold() ) );
	line++;
	
	message = new QTextEdit( this );
	message->setText("test");
	//message->setTextFormat(Qt::RichText);
	layout->addMultiCellWidget( message, line, line, 0, 1 );
	line++;

	attach = new QPushButton( tr( "&Attach" ), this );
	layout->addWidget( attach, line, 0 );
	connect( attach, SIGNAL( clicked() ), this, SLOT( attachFile() ) );

	forward = new QPushButton( tr( "Attach &Forward" ), this );
	layout->addWidget( forward, line, 1 );
	connect( forward, SIGNAL( clicked() ), this, SLOT( attachForward() ) );
	line++;

	files = new QListView( this );
	files->addColumn(tr("Attached Files"));
	layout->addMultiCellWidget( files, line, line, 0, 1 );
	line++;

	send = new QPushButton( tr( "S&end" ), this );
	layout->addWidget( send, line, 0 );
	connect( send, SIGNAL( clicked() ), this, SLOT( sendMessage() ) );

	save = new QPushButton( tr( "&Save" ), this );
	layout->addWidget( save, line, 1 );
	connect( save, SIGNAL( clicked() ), this, SLOT( saveMessage() ) );
	line++;

	sendStatus = new QLabel( this );
	layout->addMultiCellWidget( sendStatus, line, line, 0, 1 );

	LHMail::initMailSystem();

	smtp = 0;
}
Beispiel #13
0
/* -------------------------------------------------------------------- */
void saveMessage(ulong id, FILE *fl)
{
    ulong here;
    ulong loc;
    ulong result;
/*  int originroomno; */

#ifdef NEWMSGTAB
    ulong slot;
#else
    int   slot;
#endif
    FILE *fl2;
/*   label str; */


    result = indexslot(id);

#ifdef NEWMSGTAB    
    slot = indexslot(id);
#else
    slot = (int)indexslot(id);
#endif
    
    if (result == ULONG_ERROR) return;


#ifdef NEWMSGTAB
    if (getFlags(slot)->COPY)
#else
    if (msgTab_mtmsgflags[slot].COPY)
#endif

    {
        copyflag     = TRUE;
        originalId   = id;
        originalattr = 0;


#ifdef NEWMSGTAB
        originalattr = (uchar)
                       (originalattr | (getFlags(slot)->RECEIVED)?ATTR_RECEIVED :0 );
        originalattr = (uchar)
                       (originalattr | (getFlags(slot)->REPLY   )?ATTR_REPLY : 0 );
        originalattr = (uchar)
                       (originalattr | (getFlags(slot)->MADEVIS )?ATTR_MADEVIS : 0 );
#else
        originalattr = (uchar)
                       (originalattr | (msgTab_mtmsgflags[slot].RECEIVED)?ATTR_RECEIVED :0 );
        originalattr = (uchar)
                       (originalattr | (msgTab_mtmsgflags[slot].REPLY   )?ATTR_REPLY : 0 );
        originalattr = (uchar)
                       (originalattr | (msgTab_mtmsgflags[slot].MADEVIS )?ATTR_MADEVIS : 0 );
#endif

#ifdef GOODBYE                       
        if (msgTab3[slot].mtoffset <= (ushort)slot)
            saveMessage( (ulong)(id - (ulong)msgTab3[slot].mtoffset), fl);
#endif


#ifdef NEWMSGTAB
/*      if (getOriginID(slot)     <= (ushort)slot)  */
        if (long_JOIN(getToHash(slot), getAuthHash(slot))     <= slot)
#else
   /*   if (msgTab_mtomesg[slot]  <= (ushort)slot)  */

if(long_JOIN(msgTab_mttohash[slot], msgTab_mtauthhash[slot]) <= (ushort)slot) 


#endif

#ifdef NEWMSGTAB
        /*  saveMessage( (ulong)(id - (ulong)getOriginID(slot)    ), fl); */
            saveMessage( (id - long_JOIN(getToHash(slot), getAuthHash(slot))   ), fl);
#else
        /*  saveMessage( (ulong)(id - (ulong)msgTab_mtomesg[slot] ), fl);  */

            saveMessage( (ulong)(id - long_JOIN(msgTab_mttohash[slot], 
            msgTab_mtauthhash[slot])) , fl);

#endif

        return;
    }

    /* in case it returns without clearing buffer */
    msgBuf->mbfwd[  0]  = '\0';
    msgBuf->mbto[   0]  = '\0';

/*  loc = msgTab2[slot].mtmsgLoc; */

#ifdef NEWMSGTAB
    loc  = getLocation(slot);
#else
    loc  = long_JOIN(msgTab_mtmsgLocLO[slot], msgTab_mtmsgLocHI[slot]); 
#endif

    if (loc == ULONG_ERROR) return;


#ifdef NEWMSGTAB
    if (copyflag)  slot = indexslot(originalId);
#else
    if (copyflag)  slot = (int)indexslot(originalId);
#endif


#ifdef NEWMSGTAB
    if (!mayseeindexmsg(slot) && !getFlags(slot)->NET) return;
#else
    if (!mayseeindexmsg(slot) && !msgTab_mtmsgflags[slot].NET) return;
#endif

    fseek(msgfl, loc, 0);

    getMessage();
    getMsgStr(msgBuf->mbtext, MAXTEXT);

    sscanf(msgBuf->mbId, "%lu", &here);

    /* cludge to return on dummy msg #1 */
    /* if ((int)here == 1) return; */

#ifdef NEWMSGTAB
    if (!mayseemsg() && !getFlags(slot)->NET) return;
#else
    if (!mayseemsg() && !msgTab_mtmsgflags[slot].NET) return;
#endif

    if (here != id )
    {
        cPrintf("Can't find message. Looking for %lu at byte %ld!\n ",
                 id, loc);
        return;
    }

    if (msgBuf->mblink[0])
    {
        if ((fl2 = fopen(msgBuf->mblink, "rt")) == NULL)
        {
            return;
        }
        GetFileMessage(fl2, msgBuf->mbtext, MAXTEXT);
        fclose(fl2);
    }

#ifdef HENGE    
    if (node.network == NET_HENGE)
    {
        HengePutMessage(fl);
    }
    else
    {
#endif         
        PutMessage(fl);
#ifdef HENGE    
    }
#endif         
}
Beispiel #14
0
/* -------------------------------------------------------------------- */
void NewRoom(int room, char *filename)
{
#ifdef NEWMSGTAB
    ulong i;
    struct messagetable *lmt;
#else
    int i;
#endif
    ulong size_table;

    int   h;
    char str[100];
    ulong lowLim, highLim, msgNo;
    FILE *file;

    /* lowLim  = logBuf.lbvisit[ logBuf.lbroom[room].lvisit ] + 1; */

    lowLim = logBuf.newpointer[room] + 1;
    highLim = cfg.newest;

    /* logBuf.lbroom[room].lvisit = 0; */
    logBuf.newpointer[room] = cfg.newest;


    /* stuff may have scrolled off system unseen, so: */
    if (cfg.oldest  > lowLim)  lowLim = cfg.oldest;

    sprintf(str, "%s\\%s", cfg.temppath, filename);


#ifdef GOODBYE
    file = fopen(str, "ab");
    if (!file)
    {
        return;
    }
#endif

    if ((file = fopen(str, "ab")) == NULL)
    {
        /* perror("Cannot open 'room.###'"); */
        return;
    }

    h = hash(cfg.nodeTitle);

    size_table = sizetable();

#ifdef NEWMSGTAB    
    for (i = 0; i != size_table; i++)
#else
    for (i = 0; i != (int)size_table; i++)
#endif

    {

        msgNo = (ulong)(cfg.mtoldest + i);
        
        if ( msgNo >= lowLim && highLim >= msgNo )
        {
#ifdef NEWMSGTAB
            lmt = getMsgTab(i);
#endif

            /* skip messages not in this room */

#ifdef NEWMSGTAB
            if (lmt->mtroomno != room) continue;
#else
            if (msgTab_mtroomno[i] != (uchar)room) continue;
#endif
    
            /* no open messages from the system */
#ifdef NEWMSGTAB
            if (lmt->mtauthhash == h) continue;
#else
            if (msgTab_mtauthhash[i] == h) continue;
#endif
    
            /* skip mail */
#ifdef NEWMSGTAB
            if (lmt->mtmsgflags.MAIL) continue;
#else
            if (msgTab_mtmsgflags[i].MAIL) continue;
#endif
    
            /* No problem user shit */

#ifdef NEWMSGTAB
            if (
                (lmt->mtmsgflags.PROBLEM || lmt->mtmsgflags.MODERATED) 
            && !(lmt->mtmsgflags.MADEVIS)
               )
#else
            if (
                (msgTab_mtmsgflags[i].PROBLEM || msgTab_mtmsgflags[i].MODERATED) 
            && !(msgTab_mtmsgflags[i].MADEVIS)
               )
#endif
            { 
                continue;
            }

            copyflag = FALSE;
            saveMessage( msgNo, file );
            mread ++;
        }
    }
    fclose(file);
}
void AnswerMachineDialog::onBye(const AmSipRequest& req)
{
  setInOut(NULL, NULL);
  saveMessage();
  setStopped();
}
Beispiel #16
0
void iDraw()
{
	int m,n;
	iClear();
	iSetcolor(1,1,1);
	iFilledRectangle(1,1,width-19,height-18);		//draw text box
	iSetcolor(0,0,0);
	iRectangle(1,1,width-19,height-19);				//draw text boundary

	if (selflag)
	{
		for (int l=selSI; l<=selEI; l++)
		{
			int sx = (l==selSI)?( (selSJ==0)?3:selSJ*charSpace) : 3;
			int sy = height - 17 - (l+1-s)*lineSpace - 5;
			int w;
			if (l==selSI)
				w = (selSI == selEI) ? selEJ-selSJ : strlen(str+l*charMax*sizeof(char))-selSJ;
			else if (l==selEI)
				w = selEJ;
			else
				w = (strlen(str+l*charMax*sizeof(char))==0)?1:strlen(str+l*charMax*sizeof(char));

			iSetcolor(.8,.8,.9);
			iFilledRectangle(sx,sy,w*charSpace,lineSpace);
		}
	}

	iSetcolor(0,0,0);
	for (m=height-17-lineSpace, n=s; n<=imax; m-=lineSpace, n++)
	{
		iText(3, m, str+n*charMax*sizeof(char),font);		//print text
	}

	if (fOpen)
	{
		fileopen();
		iSetcolor(0,0,0);
		iText((width-15)/2-135,(height-19)/2+62,subTemp+r);		//print file open text
	}
	else if (fsave)
	{
		filesave();
		iSetcolor(0,0,0);
		iText((width-15)/2-135,(height-19)/2+62,subTemp+r);	//print file save as text
	}
	else if (aboutR)
	{
		aboutRword();
	}

	cursor();							//draw cursor		

	iSetcolor(.9,.9,.9);
	iFilledRectangle(3,height-17,width-19,17);

	iSetcolor(0,0,0);
	iLine(2,height-18,width-19,height-18);

	iSetcolor(0,0,0);
	iText(5,height-12,"File",GLUT_BITMAP_HELVETICA_12);			

	iSetcolor(0,0,0);
	iText(45,height-12,"Edit",GLUT_BITMAP_HELVETICA_12);

	iSetcolor(0,0,0);
	iText(85,height-12,"Format",GLUT_BITMAP_HELVETICA_12);

	iSetcolor(0,0,0);
	iText(141,height-12,"Help",GLUT_BITMAP_HELVETICA_12);		//draw menus
		
	if (menuflag == 1)
	{
		fileMenu();					//draw file drop down menu
	}
	else if (menuflag == 2)
	{
		editMenu();					//draw edit drop down menu
	}
	else if (menuflag == 3)
	{
		formatMenu();				//draw format drop down menu
	}
	else if (menuflag == 4)
	{
		helpMenu();					//draw help drop down menu
	}


	if (fontflag)
	{
		fontlist();						//draw font list
	}
	else if (saveM)
	{
		saveMessage();			//message box while exitting
	}

	scrollbar();                  // draw scrollbar



	if (load)
		loading();				//load window
}
Beispiel #17
0
//checks	interest of this server in Message, returns true if interested
//			interest of Satellites dependent of this Server, saves message if interested
bool ReefServer::checkInterestAndProcess(RMessage& msg, std::string body){
	bool retBool = false;

	//If Tag identifies as Message of interest for this Coral return it
	if (msg.containsAnyOf(tag_list)){
		msg.initiateWithJson(body);
		retBool = true;
	}

	//If Tag identifies as Message of interest for at least one dependent Satellite
	//save it in the Msgqueue for each Satellite with interest
	//test if MAX_MESSAGES is reached and delete Messages/Queue if necessary
	if (msg.containsAnyOf(satelliteAliases)){
		//the messages that will be sent
		std::pair<std::string, std::string> msgPair = std::make_pair(msg.getTags(), body);

		//each time the message is saved in one queue it will be checked if MAX_QUEUE is reached
		//if there is the need to delete a complete queue its name will be saved in this vector to be deleted
		//in satelliteAliases later, as we iterate over satelliteAliases and don't want to delete elements of it during the iteration
		std::vector<std::string> toBeDeleted;

		for (std::vector<std::string>::iterator it = satelliteAliases.begin(); it != satelliteAliases.end(); ++it) {

			//if a tag of the message corresponds with the current aka in satelliteAlliases
			if (msg.containsAnyOf(*it)){

				//check for MAX_MESSAGES reached, returns empty string if no Queue had to be deleted
				//otherwise returns name of queue that was deleted
				std::string tmpAKA = checkForMaxMessages();

				//if tmpAKA is not empty, save the name of the deleted Queue in toBeDeleted
				if (!tmpAKA.empty())toBeDeleted.push_back(tmpAKA);

				//save the new Message in the q of the current SatelliteAlias
				//saveMessage ignored calls to deleted Queues
				saveMessage(*it, msgPair);
			}
		}

		//finally delete the Aliases of the Queues that have been deleted in satAliases
		/*
		NOTE: This could result in horrible performance in WORST CASE, however it is really unlikely.
		WORST CASE: 1.The Server has almost as many dependend Satellites (or even more) as MAX_MESSAGES
		2.CUR_MESSAGES is almost as high as MAX_MESSAGES
		3.The Message has to be saved for (almost) all Satellites
		4.All satellites were already on the watchlist
		Then there would me many entries in the toBeDeleted vector, resulting in many
		satelliteAliases.erase(...) calls, each of which would result in copying all entries after the erased entry
		NORMAL CASE: The Network is designed in a fashion that under normal circumstances
		1.the MAX_MESSAGES won't be reached
		2.if the MAX_MESSAGES gets reached, the satellites have at leas enough time to get of the watchlist
		3.there are not that many recipience of a Message, that a complete Deletion of the longest Queue
		still doesn't give enough space
		In the NORMAL CASE toBeDeleted should have a maximum of 1 Entry, resulting in only 1 erase in satelliteAliases.
		toBeDeleted is only a Vector to be secure even in WORST CASE
		*/
		for (std::vector<std::string>::iterator it = toBeDeleted.begin(); it != toBeDeleted.end(); ++it) {
			satelliteAliases.erase(std::remove(satelliteAliases.begin(), satelliteAliases.end(), *it), satelliteAliases.end());
		}
	}
	return retBool;
}
/*!	\brief		Main function of the class.
 *		\param[in]	in		BMessage to respond to.
 */
void EventEditorMainWindow::MessageReceived( BMessage *in )
{
	BView* view;
	BEntry entry;
	BFile  file;
	BString tempString;
	BDirectory directory;
	BMessage saveMessage( kSaveRequested );
	entry_ref	ref;
	
	switch( in->what )
	{
		case B_SELECT_ALL:
		case B_COPY:
		case B_CUT:
		case B_PASTE:
		case B_UNDO:
			view = CurrentFocus();
			if ( view )
				view->MessageReceived( in );
			break;
		
		case kFileOpen:
			fOpenFile->Show();
			break;

			
		case kFileSaveAs:
			fSaveFile->Show();
			break;
		
		case kFileRevert:				// Intentional fall-through
		case kFileOpenConfirmed:
			if ( in->what == kFileRevert ) {		
				if ( fData.GetRef() != NULL )
				{
						// ...Prepare it for usage
					ref = *( fData.GetRef() );
				} else {
						// Ask the user what to do
					fOpenFile->Show();
					break;
				}
			} else {
				if ( B_OK != in->FindRef( "refs", &ref ) ||
					  B_OK != entry.SetTo( &ref, true ) ||
					  B_OK != entry.GetRef( &ref ) )
				{
					entry.Unset();
					break;
				}
			}
			fData.InitFromFile( ref );
			if ( Looper()->Lock() ) {
//				fData.Revert();
				MainView->RemoveSelf();
				delete MainView;
				InitUI();
				Looper()->Unlock();
			}
			entry.Unset();
			break;

		case kFileSave:				// Intentional fall-through			
		case kFileSaveConfirmed:
			
				// Save user's changes
			if ( genView ) genView->MessageReceived( &saveMessage );
			if ( remView ) remView->MessageReceived( &saveMessage );
			if ( actView ) actView->SaveData();
			if ( noteView ) noteView->SaveText();
			
			fData.SetEventActivityFired( false );
			fData.SetReminderActivityFired( false );
		
				// If we have the reference to file...
			if ( in->what == kFileSave ) {
				if ( fData.GetRef() != NULL )
				{
						// ...Prepare it for usage
					ref = *( fData.GetRef() );
				} else {
						// Ask the user what to do
					fSaveFile->Show();
					break;
				}				
				
			} else {
				if ( B_OK != in->FindRef( "directory", &ref ) ||
				     B_OK != in->FindString( "name", &tempString ) ||
				     B_OK != directory.SetTo( &ref ) ||
				     B_OK != directory.CreateFile( tempString.String(), NULL, false ) ||
				     B_OK != directory.FindEntry( tempString.String(), &entry, true ) ||
				     B_OK != entry.GetRef( &ref ) )
				{
					break;
				}
			}
			if ( fData.SaveToFile( &ref ) != B_OK ) {
				utl_Deb = new DebuggerPrintout( "Couldn't save file!" );	
			}
			break;
		
		case B_ABOUT_REQUESTED:
			be_app->AboutRequested();
		
		default:
		  BWindow::MessageReceived( in );
		  break;
	}
}	// <-- end of function EventEditorMainWindow::MessageReceived
void AnswerMachineDialog::process(AmEvent* event)
{
  AmAudioEvent* ae = dynamic_cast<AmAudioEvent*>(event);
  if(ae){

    switch(ae->event_id){

    case AmAudioEvent::noAudio:

      switch(status){

      case 0: {
	// announcement mode - no recording
	if (MODE_ANN == vm_mode) {
	  dlg.bye();
	  setStopped();
	  return;
	}

	playlist.addToPlaylist(new AmPlaylistItem(NULL,&a_msg));
		
	{AmArg di_args,ret;
	di_args.push(RECORD_TIMER);
	di_args.push(AnswerMachineFactory::MaxRecordTime);
	di_args.push(getLocalTag().c_str());

	user_timer->invoke("setTimer",di_args,ret);}
	status = 1;
      } break;

      case 1:
	a_beep.rewind();
	playlist.addToPlaylist(new AmPlaylistItem(&a_beep,NULL));
	status = 2;
	break;

      case 2:
	dlg.bye();
	saveMessage();
	setStopped();
	break;

      }
      break;

    case AmAudioEvent::cleared:
      DBG("AmAudioEvent::cleared\n");
      break;

    default:
      DBG("Unknown event id %i\n",ae->event_id);
      break;
    }

    return;
  }

  AmPluginEvent* plugin_event = dynamic_cast<AmPluginEvent*>(event);
  if(plugin_event && plugin_event->name == "timer_timeout" &&
     plugin_event->data.get(0).asInt() == RECORD_TIMER) {

    // clear list
    playlist.close();
  }
  else
    AmSession::process(event);
}