void BMailRemoteStorageProtocol::SyncMailbox(const char *mailbox) {
	BPath path(runner->Chain()->MetaData()->FindString("path"));
	path.Append(mailbox);
	
	BDirectory folder(path.Path());
	
	BEntry entry;
	BFile snoodle;
	BString string;
	uint32 chain;
	bool append;
	
	while (folder.GetNextEntry(&entry) == B_OK) {
		if (!entry.IsFile())
			continue;
		while (snoodle.SetTo(&entry,B_READ_WRITE) == B_BUSY) snooze(100);
		append = false;
		
		while (snoodle.Lock() != B_OK) snooze(100);
		snoodle.Unlock();
		
		if (snoodle.ReadAttr("MAIL:chain",B_INT32_TYPE,0,&chain,sizeof(chain)) < B_OK)
			append = true;
		if (chain != runner->Chain()->ID())
			append = true;
		if (snoodle.ReadAttrString("MAIL:unique_id",&string) < B_OK)
			append = true;

		BString folder(string), id("");
		int32 j = string.FindLast('/');
		if ((!append) && (j >= 0)) {
			folder.Truncate(j);
			string.CopyInto(id,j + 1,string.Length());
			if (folder == mailbox)
				continue;
		} else {
			append = true;
		}
		
		if (append)
			AddMessage(mailbox,&snoodle,&id); //---We should check for partial messages here
		else
			CopyMessage(folder.String(),mailbox,&id);
			
		string = mailbox;
		string << '/' << id;
		/*snoodle.RemoveAttr("MAIL:unique_id");
		snoodle.RemoveAttr("MAIL:chain");*/
		chain = runner->Chain()->ID();
		snoodle.WriteAttr("MAIL:chain",B_INT32_TYPE,0,&chain,sizeof(chain));
		snoodle.WriteAttrString("MAIL:unique_id",&string);
		(*manifest) += string.String();
		(*unique_ids) += string.String();
		string = runner->Chain()->Name();
		snoodle.WriteAttrString("MAIL:account",&string);
	}
}
Esempio n. 2
0
/******************************************************************************
 ** \brief CAN FD Reception Callbacks
 **
 ** \param [in] u8MsgBuf              Index of received Rx buffer.
 ** \param [in] pstcRxMsg             Address of the message content.
 ******************************************************************************/
static void CanfdRxReceivedCb0(uint8_t u8MsgBuf, stc_canfd_msg_t* pstcRxMsg)
{
	stc_canfd_msg_t	stcMsg;

	// Udate receive counter.
	u16ReceiveCounter[0]++;

	// If received message is the notification message (ID=0x100), ...
	if (pstcRxMsg->stcIdentifier.u32Identifier == MCANSAMPLE_ID_NOTIFY)
	{
		// Return same message with ID 0x200.
		CopyMessage(pstcRxMsg, &stcMsg);
		stcMsg.stcIdentifier.u32Identifier = MCANSAMPLE_ID_RETURN;
		while (Canfd_TransmitMsg((volatile stc_canfdn_t*)&CANFD0, 0, &stcMsg) == ErrorOperationInProgress)
			;
	}
}
Esempio n. 3
0
void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
{
    QModelIndex index = indexAt(e->pos());
    if (index.isValid()) {
        bool multipleSelection = false;
        mSelectionModel = selectionModel();
        if (mSelectionModel->selectedRows().count() > 1)
            multipleSelection = true;

        mContextItem = mModel.itemFromIndex(index);

        //Create a new context menu
        QMenu menu(this);

        //Store all applications in a list
        QList<QAction*> actions;

        //Create a signal mapper so we don't have to store data to class
        //member variables
        QSignalMapper *signalMapper = new QSignalMapper(this);

        if (mContextItem && mApplications->GetApplicationCount() > 0 && mContextItem->parent()) {
            //Go through all applications and add them to the context menu
            for (int i = 0; i < mApplications->GetApplicationCount(); i++) {
                //Create an action for the application
                const Application& app = mApplications->GetApplication(i);
                QAction *start = new QAction(app.getName(), &menu);
                if (multipleSelection)
                    start->setDisabled(true);

                //Add it to our list so we can disconnect later on
                actions << start;

                //Add it to context menu
                menu.addAction(start);

                //Connect the signal to signal mapper
                connect(start, SIGNAL(triggered()), signalMapper, SLOT(map()));

                //Add a new mapping
                signalMapper->setMapping(start, i);
            }

            connect(signalMapper, SIGNAL(mapped(int)),
                    this, SLOT(Context(int)));
        }

        // Add menuitems to copy full path/filename to clipboard
        if (mContextItem) {
            if (mApplications->GetApplicationCount() > 0) {
                menu.addSeparator();
            }

            //Create an action for the application
            QAction *copyfilename           = new QAction(tr("Copy filename"), &menu);
            QAction *copypath               = new QAction(tr("Copy full path"), &menu);
            QAction *copymessage            = new QAction(tr("Copy message"), &menu);
            QAction *copymessageid          = new QAction(tr("Copy message id"), &menu);
            QAction *hide                   = new QAction(tr("Hide"), &menu);
            QAction *hideallid              = new QAction(tr("Hide all with id"), &menu);
            QAction *opencontainingfolder   = new QAction(tr("Open containing folder"), &menu);

            if (multipleSelection) {
                copyfilename->setDisabled(true);
                copypath->setDisabled(true);
                copymessage->setDisabled(true);
                copymessageid->setDisabled(true);
                hideallid->setDisabled(true);
                opencontainingfolder->setDisabled(true);
            }

            menu.addAction(copyfilename);
            menu.addAction(copypath);
            menu.addAction(copymessage);
            menu.addAction(copymessageid);
            menu.addAction(hide);
            menu.addAction(hideallid);
            menu.addAction(opencontainingfolder);

            connect(copyfilename, SIGNAL(triggered()), this, SLOT(CopyFilename()));
            connect(copypath, SIGNAL(triggered()), this, SLOT(CopyFullPath()));
            connect(copymessage, SIGNAL(triggered()), this, SLOT(CopyMessage()));
            connect(copymessageid, SIGNAL(triggered()), this, SLOT(CopyMessageId()));
            connect(hide, SIGNAL(triggered()), this, SLOT(HideResult()));
            connect(hideallid, SIGNAL(triggered()), this, SLOT(HideAllIdResult()));
            connect(opencontainingfolder, SIGNAL(triggered()), this, SLOT(OpenContainingFolder()));
        }

        //Start the menu
        menu.exec(e->globalPos());

        if (mContextItem && mApplications->GetApplicationCount() > 0 && mContextItem->parent()) {
            //Disconnect all signals
            for (int i = 0; i < actions.size(); i++) {

                disconnect(actions[i], SIGNAL(triggered()), signalMapper, SLOT(map()));
            }

            disconnect(signalMapper, SIGNAL(mapped(int)),
                       this, SLOT(Context(int)));
            //And remove the signal mapper
            delete signalMapper;
        }

    }