Example #1
0
void lookupInput(){
	//Catch empty commands
	if (args[0] == NULL){
		return;
	}

	//Determine which command was executed
	if (strncmp(args[0], "exit", 4) == 0){
		keepAlive = 0;
	}else if (strncmp(args[0], "history", 7) == 0){
		if (count == 2 && atoi(args[1]) > 0){
			showHistory(atoi(args[1]));
		}else{
			showHistory(10);
		}
	}else if (strncmp(args[0], "recall", 6) == 0){
		recall(atoi(args[1]) - 1);
	}else{
		int pid = fork();
		if (!pid){
			execvp(args[0], args);
			//error handling if exec doesnt work
			printf("Please enter a valid command.\n");
			exit(1);
		}else{
			wait(NULL);
			//sleep(2);
		}
	}
}
Example #2
0
void executeHistory(icmProcessorP processor, char *cmd)
{
    int id;
    command_history_t *his;
    
    if(cmd == 0 || *cmd == '\0') {
        showHistory();        
    } else if(!strcmp(cmd, "!")) {
        if( his = lastHistory() ) {
            executeCommand(processor, his->cmd);
        } else {
            printf("ERROR: no previous command found\n");
        }                    
    } else {
        if(!getNumberFromString(cmd, & id)) {
            if( his = findHistory(id) ) {
                executeCommand(processor, his->cmd);
            } else {
                printf("ERROR: could not find history '%d'\n", id);
            }            
        } else {
            printf("ERROR: Bad number: '%s'\n", cmd);                                        
        }                
    }
}
void LLFloaterConversationPreview::draw()
{
	if(mShowHistory)
	{
		showHistory();
		mShowHistory = false;
	}
	LLFloater::draw();
}
Example #4
0
lmcCore::lmcCore(void) {
	pMessaging = new lmcMessaging();
	connect(pMessaging, SIGNAL(messageReceived(MessageType, QString*, XmlMessage*)), 
		this, SLOT(receiveMessage(MessageType, QString*, XmlMessage*)));
	connect(pMessaging, SIGNAL(connectionStateChanged()), this, SLOT(connectionStateChanged()));
	pMainWindow = new lmcMainWindow();
	connect(pMainWindow, SIGNAL(appExiting()), this, SLOT(exitApp()));
	connect(pMainWindow, SIGNAL(chatStarting(QString*)), this, SLOT(startChat(QString*)));
	connect(pMainWindow, SIGNAL(chatRoomStarting(QString*)), this, SLOT(startChatRoom(QString*)));
	connect(pMainWindow, SIGNAL(messageSent(MessageType, QString*, XmlMessage*)), 
		this, SLOT(sendMessage(MessageType, QString*, XmlMessage*)));
	connect(pMainWindow, SIGNAL(showTransfers()), this, SLOT(showTransfers()));
	connect(pMainWindow, SIGNAL(showHistory()), this, SLOT(showHistory()));
	connect(pMainWindow, SIGNAL(showSettings()), this, SLOT(showSettings()));
	connect(pMainWindow, SIGNAL(showHelp(QRect*)), this, SLOT(showHelp(QRect*)));
	connect(pMainWindow, SIGNAL(showUpdate(QRect*)), this, SLOT(showUpdate(QRect*)));
	connect(pMainWindow, SIGNAL(showAbout()), this, SLOT(showAbout()));
	connect(pMainWindow, SIGNAL(showBroadcast()), this, SLOT(showBroadcast()));
	connect(pMainWindow, SIGNAL(showPublicChat()), this, SLOT(showPublicChat()));
	connect(pMainWindow, SIGNAL(groupUpdated(GroupOp, QVariant, QVariant)),
			this, SLOT(updateGroup(GroupOp, QVariant, QVariant)));
	pPublicChatWindow = new lmcChatRoomWindow();
	connect(pPublicChatWindow, SIGNAL(messageSent(MessageType, QString*, XmlMessage*)),
		this, SLOT(sendMessage(MessageType, QString*, XmlMessage*)));
	connect(pPublicChatWindow, SIGNAL(chatStarting(QString*)), this, SLOT(startChat(QString*)));
	chatWindows.clear();
	chatRoomWindows.clear();
	pTransferWindow = NULL;
	pHistoryWindow = NULL;
	pSettingsDialog = NULL;
	pUserInfoWindow = NULL;
	pHelpWindow = NULL;
	pUpdateWindow = NULL;
	pUserSelectDialog = NULL;
	pAboutDialog = NULL;
	pBroadcastWindow = NULL;
	pTimer = NULL;
}
Example #5
0
void ProfileWidget::createActions()
{

    connect(m_showHistory, SIGNAL(clicked()), this, SLOT(showHistory()));
    connect(m_hideHistory, SIGNAL(clicked()), this, SLOT(hideHistory()));
    connect(m_giftButton, SIGNAL(clicked()), this, SLOT(showGift()));
    connect(m_submitGift, SIGNAL(clicked()), this, SLOT(hideGift()));
    connect(m_submitGift, SIGNAL(clicked()), m_parent, SLOT(s_updateCredit()));
    connect(m_counteroffer, SIGNAL(clicked()), this, SLOT(showCOTable()));
    connect(m_hideCOTable, SIGNAL(clicked()), this, SLOT(hideCOTable()));
    connect(m_counterofferTable, SIGNAL(cellClicked(int, int)),
            this, SLOT(s_buttonClicked(int,int)));
    connect(m_counterofferTable, SIGNAL(cellClicked(int,int)), m_parent, SLOT(s_updateCredit()));
}
Example #6
0
StatusTextWidget::StatusTextWidget(QWidget *parent): QWidget(parent)
{
	m_lineEdit = new StatusLineEdit(this);
	connect(m_lineEdit, SIGNAL(returnPressed()), this, SLOT(changeText()));

	StatusArrowButton *arrow = new StatusArrowButton(this);
	connect(arrow, SIGNAL(clicked()), this, SLOT(showHistory()));

	QHBoxLayout *lay = new QHBoxLayout(this);
	lay->setContentsMargins(QMargins());
	lay->setSpacing(0);
	lay->addWidget(m_lineEdit);
	lay->addWidget(arrow);
	setLayout(lay);
}
Example #7
0
void MudGameView::findText()
{
    tstring text;
    m_find_dlg.getTextToSearch(&text);
    if (text.empty())
        return;
    int view = m_find_dlg.getSelectedWindow();
    bool shift = (GetKeyState(VK_SHIFT) < 0);
    int find_direction = m_find_dlg.getDirection() * ((shift) ? -1 : 1);

    MudView *v = (view == 0) ? &m_history : m_views[view - 1];
    int current_find = v->getCurrentFindString();
    int new_find = v->findAndSelectText(current_find, find_direction, text);
    if (new_find == -1)
    {
       // not found
       if (current_find == -1)
          return;
    }
    // found / not found with last found
    // clear find in last find window (if it another window)
    if (m_last_find_view != view && m_last_find_view != -1)
    {
        MudView *lf = (m_last_find_view == 0) ? &m_history : m_views[m_last_find_view - 1];
        lf->clearFind();
        m_last_find_view = -1;
        if (new_find == -1)
            return;
    }
    if (new_find == -1)
        new_find = current_find;

    if (view == 0 && !m_history.IsWindowVisible())
        showHistory(new_find, 0);

    int count = v->getStringsCount();
    int delta = v->getStringsOnDisplay() / 2;  // center on the screen
    int center_vs = new_find + delta;          // пробуем найденную строку поставить по центру
    if (center_vs < count)
        new_find = center_vs;
    else
        new_find = count-1;
    v->setViewString(new_find);
    m_last_find_view = view;
}
Example #8
0
void ChessBoardWidget::mousePressEvent(QMouseEvent* e)
{
    if(board&&!board->isFinished()&&(showBoard!=board||historyStep!=0))
    {
        showHistory();
        showChessBoard();
    }
    else if(e->button()==Qt::LeftButton)
    {
        int cx,cy;
        QPointF p=e->localPos();

        cx=qRound((p.x()-gridLeft)/cellWidth);
        cy=qRound((p.y()-gridTop)/cellHeight);

        emit clickGrid(cx, cy);
    }
    QWidget::mousePressEvent(e);
}
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    progress = 0;
    view = new QWebView(this);
    setCentralWidget(view);
    resize(800, 600);

    // 关联信号和槽
    connect(view, SIGNAL(loadProgress(int)), this, SLOT(setProgress(int)));
    connect(view, SIGNAL(titleChanged(QString)), this, SLOT(adjustTitle()));
    connect(view, SIGNAL(loadFinished(bool)), this, SLOT(finishLoading(bool)));

    locationEdit = new QLineEdit(this);
    connect(locationEdit, SIGNAL(returnPressed()), this, SLOT(changeLocation()));

    // 向工具栏添加动作和部件
    ui->mainToolBar->addAction(view->pageAction(QWebPage::Back));
    ui->mainToolBar->addAction(view->pageAction(QWebPage::Forward));
    ui->mainToolBar->addAction(view->pageAction(QWebPage::Reload));
    ui->mainToolBar->addAction(view->pageAction(QWebPage::Stop));
    // 添加历史动作
    ui->mainToolBar->addAction(tr("历史"), this, SLOT(showHistory()));
    ui->mainToolBar->addWidget(locationEdit);

    // 设置并加载初始网页地址
    locationEdit->setText("http://www.baidu.com");
    view->load(QUrl("http://www.baidu.com"));

    // 必须先设置图标数据库路径
    view->settings()->setIconDatabasePath("./");
    connect(view, SIGNAL(iconChanged()), this, SLOT(changeIcon()));

    historyList = new QListWidget;
    historyList->setWindowTitle(tr("历史记录"));
    historyList->setMinimumWidth(300);
    connect(historyList, SIGNAL(clicked(QModelIndex)), this, SLOT(gotoHistory(QModelIndex)));
}
Example #10
0
  /**
   * Construct a history tree widget
   *
   * @param project The project to show history for
   * @param parent The Qt-relationship parent
   */
  HistoryTreeWidget::HistoryTreeWidget(Project *project, QWidget *parent) : QTreeWidget(parent) {
    m_project = project;

    QStringList headers;
    headers.append("Operation");
    headers.append("Progress");
    headers.append("Time Executed");

    setHeaderLabels(headers);

    connect(m_project, SIGNAL(workOrderStarting(WorkOrder *)),
            this, SLOT(addToHistory(WorkOrder *)));
    connect(m_project, SIGNAL(projectLoaded(Project *)),
            this, SLOT(showHistory()));
    connect(m_project->undoStack(), SIGNAL(indexChanged(int)),
            this, SLOT(handleUndoIndexChanged(int)));

    showHistory();

    refit();
  }
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    browser_ = new WebBrowser;
    browser_->loadSettings();
    browser_->GoHome();
    //setCentralWidget(browser_);
    // PESTAÑAS
    QTabWidget *tabWidgetMainWindow = new QTabWidget(this);
    tabWidgetMainWindow->setMinimumSize(800,600);
    tabWidgetMainWindow->addTab(browser_, "Pestaña 1");
    tabWidgetMainWindow->addTab(new WebBrowser, "Pestaña 2");
    tabWidgetMainWindow->setCurrentIndex(1);
    tabWidgetMainWindow->show();
    setCentralWidget(tabWidgetMainWindow);

    zoomVar = 1;    // inicialización del zoom

    // inicializamos los menus
    mainMenu_ = new QMenuBar(this);
    setMenuBar(mainMenu_);

    mnuArchivo_ = new QMenu(tr("&Archivo"), this);
    //mainMenu_ -> addMenu(mnuArchivo_);

    mnuEditar_ = new QMenu(tr("&Editar"), this);
    //mainMenu_ -> addMenu(mnuEditar_);

    mnuVer_ = new QMenu(tr("&Ver"), this);
    mainMenu_ -> addMenu(mnuVer_);
    actPlusZoom = new QAction(tr("&Aumentar zoom"), this);
    actPlusZoom -> setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Plus));
    mnuVer_->addAction(actPlusZoom);
    connect(actPlusZoom, SIGNAL(triggered()), this, SLOT(setPlusZoom()));

    actMinusZoom_ = new QAction(tr("&Disminuir zoom"), this);
    actMinusZoom_ -> setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Minus));
    mnuVer_->addAction(actMinusZoom_);
    connect(actMinusZoom_, SIGNAL(triggered()), this, SLOT(setMinusZoom()));


    mnuMarcadores_ = new QMenu(tr("&Marcadores"), this);
    mainMenu_ -> addMenu(mnuMarcadores_);
    actAddBookmark_ = new QAction(tr("&Añadir a marcadores"), this);
    actAddBookmark_ -> setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_O));
    mnuMarcadores_->addAction(actAddBookmark_);
    connect(actAddBookmark_, SIGNAL(triggered()), this, SLOT(addMarcador()));

    mnuHerramientas_ = new QMenu(tr("&Herramientas"), this);
    mainMenu_ -> addMenu(mnuHerramientas_);
    actSetHomepage_ = new QAction(tr("Establecer como pagina principal"), this);
    mnuHerramientas_->addAction(actSetHomepage_);
    connect(actSetHomepage_, SIGNAL(triggered()), browser_, SLOT(setHomepage()));

    mnuHistorial_ = new QMenu(tr("&Historial"), this);
    mainMenu_ -> addMenu(mnuHistorial_);
    actDeleteHistory_ = new QAction(tr("&Borrar el historial"), this);
    actDeleteHistory_->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_D));
    mnuHistorial_->addAction(actDeleteHistory_);
    connect(actDeleteHistory_,  SIGNAL(triggered()), this, SLOT(deleteHistory()));

    showHistory();

    readBookmarkFile();
    for (int i = 0; i < bookmarkList.size(); ++i) {
        QAction* tmp = new QAction(tr(bookmarkList.at(i).toLocal8Bit().constData()), this);
        mnuMarcadores_->addAction(tmp);
        connect(tmp,SIGNAL(triggered()),this,SLOT(PulsarMarcador()));
    }
}
Example #12
0
int Calculator::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: decSystem(); break;
        case 1: binSystem(); break;
        case 2: octSystem(); break;
        case 3: hexSystem(); break;
        case 4: realSystem(); break;
        case 5: complexSystem(); break;
        case 6: hyperbolicSystem(); break;
        case 7: changeLanguage((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 8: changePrecision(); break;
        case 9: inputNumOne(); break;
        case 10: inputNumTwo(); break;
        case 11: inputNumThree(); break;
        case 12: inputNumFour(); break;
        case 13: inputNumFive(); break;
        case 14: inputNumSix(); break;
        case 15: inputNumSeven(); break;
        case 16: inputNumEight(); break;
        case 17: inputNumNine(); break;
        case 18: inputNumZero(); break;
        case 19: inputNumA(); break;
        case 20: inputNumB(); break;
        case 21: inputNumC(); break;
        case 22: inputNumD(); break;
        case 23: inputNumE(); break;
        case 24: inputNumF(); break;
        case 25: inputNumI(); break;
        case 26: inputNumEi(); break;
        case 27: inputPoint(); break;
        case 28: inputOperAdd(); break;
        case 29: inputOperSubtract(); break;
        case 30: inputOperMultiply(); break;
        case 31: inputOperDivide(); break;
        case 32: inputOperMod(); break;
        case 33: inputOperDiv(); break;
        case 34: inputOperPercent(); break;
        case 35: inputOperFact(); break;
        case 36: inputOperComb(); break;
        case 37: inputOperPower(); break;
        case 38: inputOperSqr(); break;
        case 39: inputOperCub(); break;
        case 40: inputOperExpE(); break;
        case 41: inputOperExp10(); break;
        case 42: inputOperSqrt(); break;
        case 43: inputOperCur(); break;
        case 44: inputOperXYsqrt(); break;
        case 45: inputFunSin(); break;
        case 46: inputFunCos(); break;
        case 47: inputFunTan(); break;
        case 48: inputFunCot(); break;
        case 49: inputFunArcSin(); break;
        case 50: inputFunArcCos(); break;
        case 51: inputFunArcTan(); break;
        case 52: inputFunArcCot(); break;
        case 53: inputFunLg(); break;
        case 54: inputFunLn(); break;
        case 55: inputFunLog(); break;
        case 56: inputFunAbs(); break;
        case 57: inputFunPow(); break;
        case 58: inputFunGcd(); break;
        case 59: inputFunLcm(); break;
        case 60: inputLeftBack(); break;
        case 61: inputRightBack(); break;
        case 62: inputConst_e(); break;
        case 63: inputConst_g(); break;
        case 64: inputConst_pi(); break;
        case 65: inputConstant(); break;
        case 66: clearExpress(); break;
        case 67: backspace(); break;
        case 68: redo(); break;
        case 69: undo(); break;
        case 70: fold(); break;
        case 71: insertNewResult(); break;
        case 72: insertMemorySystem(); break;
        case 73: insertMemoryResult(); break;
        case 74: getResult(); break;
        case 75: showHistory(); break;
        case 76: showVariable(); break;
        case 77: showConstant(); break;
        case 78: setTopHint(); break;
        case 79: windowColorChange((*reinterpret_cast< QColor(*)>(_a[1]))); break;
        case 80: textviewColorChange((*reinterpret_cast< QColor(*)>(_a[1]))); break;
        case 81: expressionFontChange((*reinterpret_cast< QFont(*)>(_a[1]))); break;
        case 82: defaultSettings(); break;
        case 83: showFontDialog(); break;
        case 84: showWindowColorDialog(); break;
        case 85: showTextViewColorDialog(); break;
        case 86: setData(); break;
        case 87: setHistoryIndex(); break;
        case 88: getHugeCalcWidget(); break;
        case 89: getLinearAlgebraWidget(); break;
        case 90: getnonLinearAlgebraWidget(); break;
        case 91: help(); break;
        case 92: about(); break;
        case 93: giveSuggestions(); break;
        case 94: ElseTools(); break;
        default: ;
        }
        _id -= 95;
    }
    return _id;
}
Example #13
0
PolkaView::PolkaView(QWidget *parent)
  : QWidget( parent )
{
  m_model = new PolkaModel( this );
  connect( m_model, SIGNAL( dataWritten() ), SIGNAL( dataWritten() ) );
  
  QBoxLayout *topLayout = new QVBoxLayout( this );

  
  QBoxLayout *buttonLayout = new QHBoxLayout;
  topLayout->addLayout( buttonLayout );

  // FIXME: Use proper icon
  m_backButton = new QPushButton( "<" );
  buttonLayout->addWidget( m_backButton );
  connect( m_backButton, SIGNAL( clicked() ), SLOT( goBack() ) );
  m_backButton->setEnabled( false );

  buttonLayout->addStretch( 1 );

  m_groupNameLabel = new QLabel;
  buttonLayout->addWidget( m_groupNameLabel );

  buttonLayout->addStretch( 1 );

  m_searchEdit = new SearchEdit;
  buttonLayout->addWidget( m_searchEdit );
  connect( m_searchEdit, SIGNAL( search( const QString & ) ),
    SLOT( showSearch( const QString & ) ) );
  connect( m_searchEdit, SIGNAL( stopSearch() ), SLOT( stopSearch() ) );

  QPushButton *button = new QPushButton( i18n("...") );
  buttonLayout->addWidget( button );
  connect( button, SIGNAL( clicked() ), SLOT( showOverview() ) );

  button->setFocus();

  QBoxLayout *viewLayout = new QHBoxLayout;
  topLayout->addLayout( viewLayout );

  m_groupWidget = new QWidget;
  viewLayout->addWidget( m_groupWidget );
  
  m_listLayout = new QStackedLayout( m_groupWidget );

  m_overview = new Overview;
  m_listLayout->addWidget( m_overview );
  connect( m_overview, SIGNAL( showGroupView() ), SLOT( showGroupView() ) );
  connect( m_overview, SIGNAL( showListView() ), SLOT( showListView() ) );
  connect( m_overview, SIGNAL( showHistory() ), SLOT( showHistory() ) );

  m_groupListView = new GroupListView( m_model );
  m_listLayout->addWidget( m_groupListView );
  connectGroupView( m_groupListView );

  m_groupGraphicsView = new GroupGraphicsView( m_model );
  m_listLayout->addWidget( m_groupGraphicsView );
  connectGroupView( m_groupGraphicsView );
  connect( m_groupGraphicsView, SIGNAL( newGroup() ), SLOT( newSubGroup() ) );
  connect( m_groupGraphicsView, SIGNAL( removeIdentity( const Polka::Identity &,
    const Polka::Identity & ) ),
    SLOT( removeIdentity( const Polka::Identity &, const Polka::Identity & ) ) );
  connect( m_groupGraphicsView, SIGNAL( cloneGroup( const Polka::Identity & ) ),
    SLOT( cloneGroup( const Polka::Identity & ) ) );
  connect( m_groupGraphicsView, SIGNAL( removeGroup( const Polka::Identity & ) ),
    SLOT( removeGroup( const Polka::Identity & ) ) );
  connect( m_groupGraphicsView, SIGNAL( morphedToCompact() ),
    SLOT( finishShowPerson() ) );
  connect( m_groupGraphicsView, SIGNAL( closeRequested() ),
    SLOT( closePersonView() ) );

  m_personView = new PersonView( m_model );
  viewLayout->addWidget( m_personView );
  connect( m_personView, SIGNAL( closeRequested() ),
    SLOT( closePersonView() ) );

  m_historyView = new HistoryView( m_model );
  m_listLayout->addWidget( m_historyView );

  m_searchResultView = new SearchResultView( m_model );
  m_listLayout->addWidget( m_searchResultView );

  m_settingsWidget = new SettingsWidget( m_model );
  topLayout->addWidget( m_settingsWidget );
  connect( m_settingsWidget, SIGNAL( showView() ), SLOT( showView() ) );

  m_settingsWidget->hide();

  readConfig();

  readData();
}
/**
 *	This method processes key down events
 */
LineEditor::ProcessState LineEditor::processKeyEvent(
	KeyEvent event, std::string& resultString )
{
	#define EMPTY_STR(str) \
		(str.empty() || str.find_first_not_of(32) == std::string::npos)

	const KeyEvent::Key eventKey = event.key();

	bool isResultSet = false;
	bool isHandled = false;

	if (event.isKeyDown())
	{
		char keyChar = event.character();

		isHandled = this->processAdvanceEditKeys( event );
		if (!isHandled)
		{
			isHandled = true;
			switch (eventKey)
			{
			case KeyEvent::KEY_RETURN:
			case KeyEvent::KEY_JOY8:	// 'A' key
				if (!event.isAltDown())
				{
					resultString = editString_;
					isResultSet = true;
					editString_ = "";
					cx_ = 0;
					lastChar_ = 0;
				}
				else
				{
					isHandled = false;
				}
				break;

			case KeyEvent::KEY_DELETE:
				if ( cx_ < (int)editString_.length( ) )
					deleteChar( cx_ );
				break;

			case KeyEvent::KEY_BACKSPACE:
			case KeyEvent::KEY_JOY14:	// left trigger
				if ( cx_ )
				{
					cx_--;
					deleteChar( cx_ );
				}
				break;

			case KeyEvent::KEY_INSERT:
				inOverwriteMode_ = !inOverwriteMode_;
				break;

			case KeyEvent::KEY_LEFTARROW:
			case KeyEvent::KEY_JOY2:	// dpad left
				if ( cx_ > 0 )
					cx_--;
				break;

			case KeyEvent::KEY_RIGHTARROW:
			case KeyEvent::KEY_JOY3:	// dpad right
				if ( cx_ < (int)editString_.length() )
					cx_++;
				break;

			case KeyEvent::KEY_UPARROW:
			case KeyEvent::KEY_JOY0:	// dpad up
				if (history_.size() > 0) 
				{
					if (historyShown_ == -1)
					{
						history_.insert( history_.begin(), editString_ );
						historyShown_ = 1;
					}
					else 
					{
						if (!EMPTY_STR(editString_))
						{
							history_[historyShown_] = editString_;
						}
						++historyShown_;
					}
					showHistory();
				}
				break;

			case KeyEvent::KEY_DOWNARROW:
			case KeyEvent::KEY_JOY1:	// dpad down
				if (history_.size() > 0) 
				{
					if (historyShown_ == -1)
					{
						history_.insert( history_.begin(), editString_ );
						historyShown_ = history_.size() - 1;
					}
					else 
					{
						if (!EMPTY_STR(editString_))
						{
							history_[historyShown_] = editString_;
						}
						--historyShown_;
					}
					showHistory();
				}
				break;

			case KeyEvent::KEY_HOME:
				cx_ = 0;
				break;

			case KeyEvent::KEY_END:
				cx_ = editString_.length();
				break;

			// joystick space
			case KeyEvent::KEY_JOY15:
				keyChar = ' ';
				isHandled = false;
				break;

			default:
				isHandled = false;
				break;
			}
		}

		if (!isHandled && keyChar != 0)
		{
			isHandled = true;

			cx_ += this->insertChar( cx_, keyChar );

			lastChar_ = 0;
		}
		else if (event.isCtrlDown())
		{
			if (event.isKeyDown() && eventKey == KeyEvent::KEY_U)
			{
				int assignmentLocation = editString_.find_last_of( "=" );

				if (assignmentLocation > 0)
				{
					editString_ = editString_.substr( 0, assignmentLocation + 1 );
					cx_ = min( cx_, (int)editString_.length() );

					isHandled = true;
				}
			}
		}

		// if key is relevant (i.e. was handled) and 
		// it isn't the RETURN key, insert it into 
		// list of currently pressed-down keys
		if (isHandled && !isResultSet && this->keyRepeat_.first.key() != eventKey )
		{
			this->keyRepeat_.first  = event;
			this->keyRepeat_.second = this->time_ + KEY_REPEAT_START_SEC;
		}
		if( this->keyRepeat_.first.modifiers() != event.modifiers() )
		{
			this->keyRepeat_.first = KeyEvent( keyRepeat_.first.type(), 
				keyRepeat_.first.key(), event.modifiers() );
		}
	}
	else
	{
		// this is a key-up event. 
		// Stop key from repeating
		if (eventKey == this->keyRepeat_.first.key() ||
			event.isCtrlDown() || event.isAltDown() )
		{
			this->keyRepeat_.first = KeyEvent();
			this->keyRepeat_.second = FLT_MAX;
			this->time_ = 0;
		}
		else if( this->keyRepeat_.first.modifiers() != event.modifiers() )
		{
			this->keyRepeat_.first = KeyEvent( keyRepeat_.first.type(), 
				keyRepeat_.first.key(), event.modifiers() );
		}
	}

	// these are key up and key downs
	if (!isHandled) switch (eventKey)
	{
		// any joystick button or quantized direction 
		// change and we go and update our joystick state
		case KeyEvent::KEY_JOYALPUSH:
		case KeyEvent::KEY_JOYARPUSH:
		case KeyEvent::KEY_JOYALUP:
		case KeyEvent::KEY_JOYALDOWN:
		case KeyEvent::KEY_JOYALLEFT:
		case KeyEvent::KEY_JOYALRIGHT:
		case KeyEvent::KEY_JOYARUP:
		case KeyEvent::KEY_JOYARDOWN:
		case KeyEvent::KEY_JOYARLEFT:
		case KeyEvent::KEY_JOYARRIGHT:
			this->processJoystickStates(
				InputDevices::joystick().stickDirection( 1 ),
				InputDevices::joystick().stickDirection( 0 ),
				InputDevices::isKeyDown( KeyEvent::KEY_JOYARPUSH ),
				InputDevices::isKeyDown( KeyEvent::KEY_JOYALPUSH ) );
			isHandled = true;
			break;
	}

	// end of line, request processing
	if (isResultSet)
	{
		if (!EMPTY_STR(resultString))
		{
			if (history_.size() > 0 && historyShown_ != -1)
			{
				history_[ 0 ] = resultString;
			}
			else
			{
				history_.insert( history_.begin(), resultString );
			}
		}
		else
		{
			if (history_.size() > 0 && EMPTY_STR(history_[ 0 ]))
			{
				history_.erase(history_.begin());
			}
		}
		// clamp history 
		if (history_.size() > MAX_HISTORY_ENTRIES)
		{
			history_.erase( history_.end()-1 );
		}
		historyShown_ = -1;
		return RESULT_SET;
	}

	if (isHandled)
	{
		return PROCESSED;
	}

	return NOT_HANDLED;
}
Example #15
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent)
{
    setupUi(this);

    Finished_Init = false;
    AllowInit = false;
    PreBuf_timer = new QTimer;
    Update_timer= new QTimer;
    Ping_timer= new QTimer;
    Spectrum_timer = new QTimer;
    BufferStatusUpdate_timer= new QTimer;
    singleClickTimer=new QTimer;
    m_msgbox = NULL;
    isPlaying=false;
    syncLost=false;
    currentRadio=NULL;
    currentTrack="";
    dConnectionProgress=NULL;
    dDelConfirm=NULL;
    dShowHistory=NULL;
    netManager=NULL;
    currentRadioURL=-1;
    streamsErrLoop=false;
    pSpec=NULL;
    mMoving=false;
    savedVolume=0.5;
    isMuted=false;
    treeSelectionChanged=false;
    isRecording=false;
    newVersionAnimation=NULL;
    recButtonAnimation=NULL;
    isRootOperation=false;
#ifdef VISUALS
    isVisResized=false;
    isVisRendering=false;
    visWin=new VisWinCL(this);
    bigVis=false;
    bigVisRunning=false;
#endif

    initBitRate();
    initOggQualityMap();

    qDebug()<<"Cheking BASS version";
    if (HIWORD(BASS_GetVersion())!=BASSVERSION) {
        qDebug()<<"An incorrect version of BASS.DLL was loaded";
        QMessageBox::warning(this,QString("warning"),QString("An incorrect version of BASS.DLL was loaded"));
    }

    BASS_SetConfigPtr(BASS_CONFIG_NET_AGENT, (void*) _T(PLAYER_HTTPAGENT));


#ifdef Q_OS_WIN
    if (BASS_PluginLoad("bass_aac.dll",0)==0) {
        qDebug()<<"Unable to load bass_aac.ddl  BassError="<<BASS_ErrorGetCode();
    }
#elif Q_OS_LINUX
    if (BASS_PluginLoad("bass_aac.so",0)==0) {
        qDebug()<<"Unable to load bass_aac.ddl  BassError="<<BASS_ErrorGetCode();
    }
#endif


    QSettings tSettings(AppPath+CONFIG_FILENAME,QSettings::IniFormat);
    tSettings.setIniCodec("ISO 8859-1");
    Proxy=tSettings.value("proxy","").toString();
    ProxyPort=tSettings.value("proxyport","").toString();
    ProxyUser=tSettings.value("proxyuser","").toString();
    ProxyPass=tSettings.value("proxypass","").toString();
    visualPlugin=tSettings.value("visual",VIS_WIN_PLUG).toString();
    qDebug()<<"visualPlugin="<<visualPlugin;
    recPath=tSettings.value("recpath","").toString();
    recPath=recPath.replace("\\","\\\\");
#ifdef Q_OS_WIN
    if (recPath!="" && recPath.at(recPath.length()-1)!='\\')
        recPath=recPath+"\\";
#else
    if (recPath!="" && recPath.at(recPath.length()-1)!='/')
        recPath=recPath+"/";
#endif

    if (recPath=="") {
#ifdef Q_OS_WIN
        recPath=QDir::toNativeSeparators(QStandardPaths::standardLocations(QStandardPaths::MusicLocation).at(0)+"/");
#endif

#ifdef Q_OS_MAC
        recPath=AppPath.fromLatin1(argv[0]);
        recPath+="/";
#endif
    }

    qDebug()<<"Recording path ="<<recPath;

    if (Proxy!="") {
        qDebug()<<"Proxy="<<Proxy;
        QString tBassProxyStr=ProxyUser;
        if (ProxyPass!="")
            tBassProxyStr+=":"+ProxyPass;
        if (ProxyUser!="")
            tBassProxyStr+="@";
        tBassProxyStr+=Proxy+":"+ProxyPort;
        qDebug()<<"BASSProxy="<<tBassProxyStr;
        qDebug()<<"BASSProxy="<<tBassProxyStr.toLatin1().data();
        //strcpy(proxyStrChar,Proxy.toLatin1().data());
        BASS_SetConfigPtr(BASS_CONFIG_NET_PROXY,tBassProxyStr.toLatin1().data());
        //BASS_SetConfigPtr(BASS_CONFIG_NET_PROXY,&proxyStrChar);
    }
    else {
        BASS_SetConfigPtr(BASS_CONFIG_NET_PROXY, NULL);
    }

    //if( !InitVersion() ) ErrorMsgBox(_T("\n Error Setting up Version strings \n"));
    if( !InitBassErrorMap() ) ErrorMsgBox(_T("\n Error setting up Error Msgs \n"));
    if (!BASS_Init(-1,44100,0,NULL,NULL)) {
        ErrorMsgBox(_T("\nUnable to initialize BASS library\n"), 86, false);
        exit(86);
    }

    savedVolume=BASS_GetVolume();
    slVolume->setValue(savedVolume*slVolume->maximum());


#ifdef Q_OS_WIN
    // allocate ACM format buffer, using suggested buffer size
    acmformlen = BASS_Encode_GetACMFormat(0,NULL,0,NULL,0);
    acmform = (WAVEFORMATEX*)malloc(acmformlen);
    memset(acmform,0,acmformlen);
    acmduncil = (WAVEFORMATEX*)malloc(acmformlen);
    memset(acmduncil, 0, acmformlen);
    //
#endif

    connect(radioTree,SIGNAL(AddStationSig(QModelIndex,RadioCL*)),this,SLOT(AddStation(QModelIndex,RadioCL*)));
    connect(radioTree, SIGNAL(treeSelectionChanged(const QModelIndex &, const QModelIndex &)), this,
            SLOT(radioTreeSelectionChanges(const QModelIndex &, const QModelIndex &)));

    qDebug()<<"Connecting timers signals ";
    connect(PreBuf_timer, SIGNAL(timeout()), this, SLOT(prebufTimeout()));
    connect(Update_timer, SIGNAL(timeout()), this, SLOT(updateTimeout()));
    connect(Ping_timer, SIGNAL(timeout()),this, SLOT(pingRadio()));
    connect(Spectrum_timer, SIGNAL(timeout()), this, SLOT(specTimeout()));
    connect(BufferStatusUpdate_timer, SIGNAL(timeout()),this, SLOT(updateBufferStatus()));
    connect(singleClickTimer, SIGNAL(timeout()),this, SLOT(singleClickTimeout()));

    qDebug()<<"Connecting mgh signals";
    connect( &mgh, SIGNAL(SendUpdTrackInfo(QString)), this, SLOT(on_UpdTrackInfo(QString)) );
    connect( &mgh, SIGNAL(SendUpdRadioInfo(QString,QString,QString,QString)), this, SLOT(on_UpdRadioInfo(QString,QString,QString,QString)));
    connect( &mgh, SIGNAL(SendSyncLost()), this, SLOT(on_SyncLost()) );
    connect( &mgh, SIGNAL(SendPlaybackStarts()), this, SLOT(on_PlaybackStarts()) );
    connect( &mgh, SIGNAL(SendClickRecord()), this, SLOT(on_ClickRecord()) );

    qDebug()<<"Creating actions";
    createActions();
    qDebug()<<"Creating tray icon";
    createTrayIcon();

    qDebug()<<"Setting tray icon";
    setIcon(PLAYER_STATUS_INACTIVE);
    trayIcon->setVisible(true);
    trayIcon->show();
    setWindowTitle(QString(PLAYER_NAME)+" v"+RADIOLA_VERSION);

    qDebug()<<"Initializing spectrum image";
    specbuf = NULL;
    specmode = DEFAULT_SPEC_MODE; // spectrum mode
    specpos = 0; // spectrum mode (and marker pos for 2nd mode)
    pSpec = new QImage(SPECWIDTH, SPECHEIGHT, QImage::Format_Indexed8);
    // setup palette
    pSpec->setColor(0, qRgb(0,0,0));
    for(int a=1; a < 128; a++) {
        pSpec->setColor(a, qRgb(2*a, 256-2*a, 0));
    }
    for(int a=0; a < 32; a++) {
        pSpec->setColor(128+a, qRgb(0, 0, 8*a));
        pSpec->setColor(128+32+a, qRgb(8*a, 0, 255));
        pSpec->setColor(128+64+a, qRgb(255, 8*a, 8*(31-a)));
        //pSpec->setColor(128+64+a, qRgb(8*(31-a), 8*a, 8*a));
        pSpec->setColor(128+96+a, qRgb(255, 255, 8*a));
        //pSpec->setColor(128+96+a, qRgb(255, 255, 8*a));
    }
    pSpec->setColor(254, qRgb(112, 112, 255));
    pSpec->setColor(253, qRgb(255, 128, 128));
    pSpec->setColor(255, qRgb(212,208,200));    // background color
    // create the bitmap
    specbuf = (BYTE*)pSpec->bits();
    pSpec->fill(255);
    specButton->setSpec(pSpec);

    readSettings();

    qDebug()<<"Connecting tray signals ";
    connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
            this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason)));

    setupRadioTree();

    historyFile.setFileName(GetHistoryDir());

    if (!historyFile.open(QIODevice::ReadWrite | QIODevice::Append)) {
        qDebug()<<"Unable to open history file for write"<<historyFile.fileName();
        return;
    }

    StopPlayback();

    QIcon icon = QIcon(MAINWIN_ICON);
    setWindowIcon(icon);

    new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_S), this, SLOT(showSettings()));
    new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_E), this, SLOT(showRecPath()));
    new QShortcut(QKeySequence(Qt::Key_F1), this, SLOT(showHelp()));
    new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_H), this, SLOT(showHistory()));
#ifdef Q_OS_WIN
    new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_V), this, SLOT(showVisualization()));
#endif
    new QShortcut(QKeySequence(Qt::Key_Space), this, SLOT(on_pbPlay_clicked()));
    new QShortcut(QKeySequence(Qt::Key_MediaPlay), this, SLOT(on_pbPlay_clicked()));
    new QShortcut(QKeySequence(Qt::Key_Delete), this, SLOT(removeRow()));
    new QShortcut(QKeySequence(Qt::Key_Insert), this, SLOT(insertStation()));
    new QShortcut(QKeySequence(Qt::Key_Plus), this, SLOT(insertSubfolder()));

    QGraphicsDropShadowEffect* effect = new QGraphicsDropShadowEffect();
    effect->setBlurRadius(1); //Adjust accordingly
    effect->setOffset(3,3); //Adjust accordingly
    setShadow(bnShowHistory);
    setShadow(pbPlay);
    setShadow(pbRecord);
    setShadow(pbQuit);

    recButtonAnimation=new QMovie(":/images/rec_animation.gif");
    connect(recButtonAnimation,SIGNAL(frameChanged(int)),this,SLOT(setRecButtonIcon(int)));

    singleClickTimer->setInterval(QApplication::doubleClickInterval());
    singleClickTimer->setSingleShot(true);

    CheckNewVersion();

    netManager = new QNetworkAccessManager(this);
    if (Proxy!="") {
        netManager->setProxy(QNetworkProxy(QNetworkProxy::HttpProxy,Proxy,ProxyPort.toInt(),ProxyUser,ProxyPass));
    }
    connect(netManager, SIGNAL(finished(QNetworkReply*)),this, SLOT(pingReply(QNetworkReply*)));
}
Example #16
0
////////////////////////////////////////////////
// main - start
////////////////////////////////////////////////
int main(int argc, char *argv[]) 
{
	
	int verbose_on = 0; 
	char txtbuf[MAX_TXT_LENGTH];
	int current_number = 1; //starting number seems to be one
	char copy[MAX_TXT_LENGTH];
	int continue_loop = 1;
	
	struct ParsingResult *parres = (struct ParsingResult*)malloc( sizeof(struct ParsingResult ) ); 
	parres->numArgs = 0;
	parres->type = 0;
	struct History *history = (struct History*)malloc( sizeof(struct History ) ); 
	history->hnum = 0;
	
	while( continue_loop )
	{
		printf("mish[%d]> ", current_number);
		if( fgets(txtbuf,MAX_TXT_LENGTH,stdin) == NULL ) {
			break;
		}
		// Locate the newline character in the buffer,
		// and replace it with a NUL character
		int i = 0;
		while( txtbuf[i] != '\0' && txtbuf[i] != '\n' ) {
			i++;
		}
		if( txtbuf[i] == '\n' ) {
			txtbuf[i] = '\0';
		}
		
		//since txtbuf gets altered after this point, lets take the copy now
		strcpy(copy,txtbuf);
		
		parseInput(txtbuf,parres);
		
		//originally located above with the rest, but due to the nature
		//of the command it must be placed up here before it is it used
		if(parres->type == 1 && strcmp(parres->strs[0],"verbose")==0)
		{
			verbose_on = (strcmp(parres->strs[1],"on")==0);
		}
		
		if(verbose_on)
		{//and so verbose said, "Let there be cake! -I mean info, let there be info"
			printf("	command: %s\n\n	input command tokens:\n",copy);
			int q = 0;
			while(q < parres->numArgs)
			{
				printf( "	%d: %s\n",q,parres->strs[q]);
				q++;
			}
			
		}
		if(parres->type != 0)//command entered, lets archive it
		{
			addToHistory(copy,history);
		}
		
		//think of parres->type as an enum
		if(parres->type == 1)//internal commands
		{
			if(strcmp(parres->strs[0],"help")==0)
			{
				showHelp();
			}
			else if(strcmp(parres->strs[0],"quit")==0)
			{
				continue_loop = 0;
			}
			else if(strcmp(parres->strs[0],"history")==0)
			{
				showHistory(history);
			}
			//else if(strcmp(parres->strs[0],"verbose")==0)
			//{
			//	//filtered everything out from the parse function,
			//	//only on and off are possible
			//	verbose_on = (strcmp(parres->strs[1],"on")==0);
			//}
			current_number++;
		}
		else if(parres->type == 3)
		{
			//an error has occurred in the internal functions,
			//we must inform the masses
			printf("%s\n",parres->display);
		}
		else if(parres->type == 2)
		{	
			externalCommands(parres,verbose_on);
			current_number++;
		}
	}
	
	free(parres);
	free(history);	
	
	return 0;
}
Example #17
0
void QtSystray::setTrayMenu() {
	_trayMenu->clear();

	//openAction
#if defined(OS_MACOSX)
	// On Mac OS X, clicking the Dock icon should show the application thus the
	// 'Open WengoPhone' entry is not necessary. We get the Dock Icon click event
	// from our QtMacApplication class.
	QtMacApplication * qMacApp = dynamic_cast<QtMacApplication *>(QApplication::instance());
	SAFE_CONNECT_RECEIVER(qMacApp, SIGNAL(applicationMustShow()), _qtWengoPhone->getWidget(), SLOT(show()));
#endif
	_startNew = new QMenu(tr("Start New"));
	
	_newCall = new QAction(tr("Call"), _startNew);
	_newConference = new QAction(tr("Conference Call"), _startNew);
	//_newInstantMessage = new QMenu(tr("Instant Message"));
	_newInstantMessage = new QAction(tr("Instant Message"), _startNew);
	_newGroupChat = new QAction(tr("Group Chat"), _startNew);
	_newTextMessage = new QAction(tr("Text Message"), _startNew);
	_newGroupTextMessage = new QAction(tr("Group Text Message"), _startNew);
	_newEmail = new QAction(tr("Email"), _startNew);
	_newGroupEmail = new QAction(tr("Group Email"), _startNew);
	_newSendFile = new QAction(tr("Send File"), _startNew);
	_newSendFax = new QAction(tr("Send Fax"), _startNew);

	SAFE_CONNECT_RECEIVER(_newCall, SIGNAL(triggered()), _qtToolBar, SLOT(showKeyTab()));
	SAFE_CONNECT_RECEIVER(_newConference, SIGNAL(triggered()), _qtToolBar, SLOT(createConferenceCall()));
	/*_newInstantMessage->clear();
	SAFE_CONNECT(_newInstantMessage, SIGNAL(triggered(QAction *)), SLOT(startChat(QAction *)));
	QtContactMenu::populateChatMenu(_newInstantMessage, _qtWengoPhone->getCWengoPhone());*/
	_newInstantMessage->setDisabled(true);
	_newGroupChat->setDisabled(true);
	_newTextMessage->setDisabled(true);
	_newGroupTextMessage->setDisabled(true);
	_newEmail->setDisabled(true);
	_newGroupEmail->setDisabled(true);
	_newSendFile->setDisabled(true);
	_newSendFax->setDisabled(true);
	
	_startNew->addAction(_newCall);
	_startNew->addAction(_newConference);
	_startNew->addAction(_newInstantMessage);
	//_startNew->addMenu(_newInstantMessage);
	_startNew->addAction(_newGroupChat);
	_startNew->addAction(_newTextMessage);
	_startNew->addAction(_newGroupTextMessage);
	_startNew->addAction(_newEmail);
	_startNew->addAction(_newGroupEmail);
	_startNew->addAction(_newSendFile);
	_startNew->addAction(_newSendFax);	

	_recentContacts = new QMenu(tr("Recent Contacts"));
	_viewConversations = new QAction(tr("View Conversations"), _trayMenu);
	_showContactList = new QAction(tr("Show Contact List"), _trayMenu);
	_settings = new QAction(tr("Settings"), _trayMenu);
	_signOut = new QAction(tr("Sign Out"), _trayMenu);
	_quit = new QAction(tr("Quit @product@"), _trayMenu);
	
	_recentContacts->setDisabled(true);
	SAFE_CONNECT_RECEIVER(_viewConversations, SIGNAL(triggered()), _qtToolBar, SLOT(showHistory()));
	SAFE_CONNECT_RECEIVER(_showContactList, SIGNAL(triggered()), _qtToolBar, SLOT(showContactsTab()));
	SAFE_CONNECT_RECEIVER(_settings, SIGNAL(triggered()), _qtToolBar, SLOT(showConfig()));
//	SAFE_CONNECT_RECEIVER(_signOut, SIGNAL(triggered()), _qtToolBar, SLOT(logOff()));
//	SAFE_CONNECT_RECEIVER(_quit, SIGNAL(triggered()), _qtWengoPhone, SLOT(prepareToExitApplication()));	
	SAFE_CONNECT_RECEIVER(_signOut, SIGNAL(triggered()), _qtWengoPhone, SLOT(logOff()));					//VOXOX - JRT - 2009.07.13 
	SAFE_CONNECT_RECEIVER(_quit,	SIGNAL(triggered()), _qtWengoPhone, SLOT(exitApplication()));			//VOXOX - JRT - 2009.07.13 
	
	if(!_qtToolBar->getUserIsLogged()){
		_startNew->setDisabled(true);
		_viewConversations->setDisabled(true);
		_showContactList->setDisabled(true);
		_settings->setDisabled(true);
		_signOut->setDisabled(true);
	}

	_trayMenu->addMenu(_startNew);
	_trayMenu->addMenu(_recentContacts);
	_trayMenu->addAction(_viewConversations);
	_trayMenu->addAction(_showContactList);
	if ( getCUserProfile() ) {
		_trayMenu->addMenu(createStatusMenu());
	}
	_trayMenu->addAction(_settings);
	_trayMenu->addAction(_signOut);
	_trayMenu->addAction(_quit);

	_trayIcon->setPopup(_trayMenu);
}
Example #18
0
void loop_SHELL()
{
	FILE* _io_=fopen("commands.txt","a+");
	
	realpath("commands.txt", history_file_path);
	
   	while(1)
	{
		char cwd[MAX_SIZE];
		char buf[MAX_SIZE];

		FILE* _out_;

		if(getcwd(cwd, MAX_SIZE) != NULL)
		printf(" %s > ",cwd);
		
		else{
			printf("Command Prompt error ! Terminating...\n ");
			exit(1);
		}

		if(fgets(buf, MAX_SIZE, stdin)==NULL)
			continue;

		if(strlen(buf)<=1)
			continue;

		if(updateHistory(buf)==-1)
			printf("Trouble updating History !\n");

		char **args = (char**)malloc(MAX_SIZE*sizeof(char*));

		char** p =args;

		*p=strtok(buf, " \t\n");

		while(*p!=NULL)
		{
			p++;
			*p=strtok(NULL, " \t\n");
		}

		if(args==NULL)
			continue;

		if(strcmp(args[0],"clear")==0 && args[1]==NULL)
			clrscreen();

		else if(strcmp(args[0],"ls")==0)
			listContents(args[1]);

		else if(strcmp(args[0],"env")==0 && args[1]==NULL)
			showEnvironmentVariables();

		else if(strcmp(args[0],"exit")==0 && args[1]==NULL)
			exit(0);

		else if(strcmp(args[0],"pwd")==0 && args[1]==NULL)
		{
			if (showWorkingDirectory() == -1)
				printf("Error showing current directory !\n");
		}

		else if(strcmp(args[0],"cd")==0)
		{
			if(changeDirectory(args[1])==-1)
				printf("ERROR : No such directory exists!\n");
		}
		
		else if(strcmp(args[0],"mkdir")==0)
		{
			if(args[1]==NULL)
				printf("Invalid Command ! Please enter : \n mkdir <dir_name>\n");
			else if(makeDirectory(args[1])==-1)
				printf("ERROR in creating directory !\n");
		}

		else if(strcmp(args[0],"rmdir")==0)
		{
			if(args[1]==NULL)
				printf("Invalid Command ! Please enter : \n rmdir <dir_name>\n");
			else if(removeDirectory(args[1])==-1)
				printf("ERROR in deleting directory !\n");
		}

		else if(strcmp(args[0],"history")==0)
		{
			if(showHistory(args[1])==-1)
				printf("ERROR ! Trouble showing history !\n");
		}
		
		else executeCommand(args);
	}

}