Пример #1
0
/**
 * @function    runCommand
 *
 * @abstract    Parses and executes a command given a NULL terminated string.
 * @discussion  Parses the command and adds it to the history if it is
 *              nontrivial.
 *
 * @param       cmd_buffer      Pointer to NULL terminated string containing
 *                              the user input.
 * @result      Returns nothing, but runs a command, most likely printing to
 *              the terminal.
 */
void runCommand(char* cmd_buffer) {
    Command *command = NULL;
    yyscan_t scanner;
    YY_BUFFER_STATE state;

    // Check if there is anything in the line.  It is useless to store
    // a history of empty lines.  If it is not empty, then add it to our
    // history.  Also don't want to record line rerun calls.
    if ((cmd_buffer[0] != 0) && (cmd_buffer[0] != '!')) {
        add_history(cmd_buffer);
    }

    state = yy_scan_string(cmd_buffer);

    if (yyparse(&command, scanner)) {
        printf("Error in parsing command.\n");
        deleteCommand(command);
        return;
    }

    executeCommand(command, -1);
    deleteCommand(command);

    // Wait on all child processes
    while (wait(NULL) > 0) {}

    yy_delete_buffer(state);

    yylex_destroy();

    return;
}
Пример #2
0
void TextCommandEditor::action(const ActionEvent &event)
{
    const std::string &eventId = event.getId();
    if (eventId == "magic")
    {
        mIsMagicCommand = true;
        showControls(Visible_true);
    }
    else if (eventId == "other")
    {
        mIsMagicCommand = false;
        showControls(Visible_false);
    }
    else if (eventId == "save")
    {
        save();
        scheduleDelete();
    }
    else if (eventId == "cancel")
    {
        scheduleDelete();
    }
    else if (eventId == "delete")
    {
        deleteCommand();
        scheduleDelete();
    }
}
Пример #3
0
void MainPanel::pressButtonSlot(int button)
{
    switch(button)
    {
    case CommandButtons::BUTTON_VIEW:
        viewCommand();
        break;

    case CommandButtons::BUTTON_EDIT:
        editCommand();
        break;

    case CommandButtons::BUTTON_COPY:
        copyCommand();
        break;

    case CommandButtons::BUTTON_MOVE:
        moveCommand();
        break;

    case CommandButtons::BUTTON_MK_DIR:
        mkdirCommand();
        break;

    case CommandButtons::BUTTON_DELETE:
        deleteCommand();
        break;

    case CommandButtons::BUTTON_EXIT:
        exitCommand();
        break;
    }
}
   bool
   PersistentDistributionList::DeleteObject(std::shared_ptr<DistributionList> pDistList)
   {
      if (pDistList->GetID() == 0)
      {
         assert(0);
         return false;
      }

      DeleteMembers(pDistList);

      SQLCommand deleteCommand("delete from hm_distributionlists where distributionlistid = @LISTID");
      deleteCommand.AddParameter("@LISTID", pDistList->GetID());

      bool bResult = Application::Instance()->GetDBManager()->Execute(deleteCommand);
   
      Cache<DistributionList>::Instance()->RemoveObject(pDistList);

      return bResult;
   }
Пример #5
0
bool
PersistentAccount::DeleteObject(boost::shared_ptr<Account> pAccount)
{
    __int64 iID = pAccount->GetID();
    assert(iID);

    if (iID <= 0)
        return false;

    // Delete messages connected to this account.
    DeleteMessages(pAccount);

    // Force delete the inbox as well. DeleteMessages above does not delete it.
    boost::shared_ptr<IMAPFolder> inbox = pAccount->GetFolders()->GetFolderByName("Inbox");
    if (inbox)
        PersistentIMAPFolder::DeleteObject(inbox, true);

    pAccount->GetRules()->DeleteAll();

    // Delete fetch accounts connected to this account.
    PersistentFetchAccount::DeleteByAccountID(iID);

    // Delete references from groups...
    PersistentGroupMember::DeleteByAccount(iID);

    PersistentACLPermission::DeleteOwnedByAccount(iID);

    SQLCommand deleteCommand("delete from hm_accounts where accountid = @ACCOUNTID");
    deleteCommand.AddParameter("@ACCOUNTID", iID);

    bool bRet = Application::Instance()->GetDBManager()->Execute(deleteCommand);

    // Delete folder from data directory
    String sAccountFolder = IniFileSettings::Instance()->GetDataDirectory() + "\\" + StringParser::ExtractDomain(pAccount->GetAddress()) + "\\" + StringParser::ExtractAddress(pAccount->GetAddress());
    FileUtilities::DeleteDirectory(sAccountFolder);

    // Refresh caches.
    Cache<Account, PersistentAccount>::Instance()->RemoveObject(pAccount);

    return bRet;
}
Пример #6
0
void MainPanel::keyPressEvent(QKeyEvent* event)
{
    if(event == NULL)
        return QWidget::keyPressEvent(event);

    switch(event->key())
    {
    case Qt::Key_Left:
    case Qt::Key_Right:
        m_line->setFocus();
        break;

    case Qt::Key_F3:
        viewCommand();
        break;

    case Qt::Key_F4:
        editCommand();
        break;

    case Qt::Key_F5:
        copyCommand();
        break;

    case Qt::Key_F6:
        moveCommand();
        break;

    case Qt::Key_F7:
        mkdirCommand();
        break;

    case Qt::Key_F8:
        deleteCommand();
        break;
    }

    if(event->key() == Qt::Key_Left || event->key() == Qt::Key_Right)
        m_line->setFocus();
}