Esempio n. 1
0
void FileBrowser::onAccessGridPressed()
{
    //select files from AG dta store
    this->mLocation = "AccessGrid";
    emit locationChanged(this->mLocation);
    emit dirChange(QString(""));
}
Esempio n. 2
0
void csWrappedDocumentNode::ProcessInclude (const TempString<>& filename,
					    NodeProcessingState* state, 
					    iDocumentNode* node)
{
  iVFS* vfs = globalState->vfs;
  csRef<iDataBuffer> pathExpanded = vfs->ExpandPath (filename);
  
  csRef<iDocumentNode> includeNode;
  includeNode = globalState->includesCache.Get (pathExpanded->GetData(),
    (iDocumentNode*)0);
  if (!includeNode.IsValid())
  {
    csRef<iFile> include = vfs->Open (filename, VFS_FILE_READ);
    if (!include.IsValid ())
    {
      Report (syntaxErrorSeverity, node,
	"could not open %s", CS::Quote::Single (filename.GetData ()));
    }
    else
    {
      csRef<iDocumentSystem> docsys (
	csQueryRegistry<iDocumentSystem> (shared->objreg));
      if (!docsys.IsValid())
	docsys.AttachNew (new csTinyDocumentSystem ());
  
      csRef<iDocument> includeDoc = docsys->CreateDocument ();
      const char* err = includeDoc->Parse (include, false);
      if (err != 0)
      {
	Report (syntaxErrorSeverity, node,
	  "error parsing %s: %s", CS::Quote::Single (filename.GetData ()), err);
	return;
      }
      else
      {
	csRef<iDocumentNode> rootNode = includeDoc->GetRoot ();
        includeNode = rootNode->GetNode ("include");
	if (!includeNode)
	{
	  Report (syntaxErrorSeverity, rootNode,
	    "%s: no <include> node", filename.GetData ());
	  return;
	}
	globalState->includesCache.Put (pathExpanded->GetData(),
          includeNode);
      }
    }
  }
  
  csVfsDirectoryChanger dirChange (vfs);
  dirChange.ChangeTo (filename);

  csRef<iDocumentNodeIterator> it = includeNode->GetNodes ();
  while (it->HasNext ())
  {
    csRef<iDocumentNode> child = it->Next ();
    ProcessSingleWrappedNode (state, child);
  }
}
Esempio n. 3
0
FileBrowser::FileBrowser(TUIFileBrowserButton *instance, QWidget *parent, int id)
{
    Q_UNUSED(parent);

    this->mTUIElement = instance;
    this->CreateDialogLayout();
    connect(lstDir, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(onLstDirDoubleClick(QListWidgetItem *)));
    connect(lstFile, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(onLstFileDoubleClick(QListWidgetItem *)));
    connect(lstFile, SIGNAL(itemClicked(QListWidgetItem *)), this, SLOT(onLstFileClick(QListWidgetItem *)));
    connect(btnCancel, SIGNAL(pressed()), this, SLOT(onCancelPressed()));
    connect(txtFilename, SIGNAL(textEdited(QString)), this, SLOT(onFilenameChanged(QString)));
    connect(txtFilename, SIGNAL(returnPressed()), this, SLOT(onAcceptPressed()));
    connect(this, SIGNAL(fileNameEntered()), this, SLOT(onAcceptPressed()));
    connect(cmbFilter, SIGNAL(activated(int)), this, SLOT(onFilterActivated(int)));
    connect(btnHome, SIGNAL(pressed()), this, SLOT(onHomePressed()));
    connect(btnMachine, SIGNAL(pressed()), this, SLOT(onMachinePressed()));
    connect(btnRemote, SIGNAL(pressed()), this, SLOT(onRemotePressed()));
    connect(btnAccessGrid, SIGNAL(pressed()), this, SLOT(onAccessGridPressed()));
    connect(cmbDirectory, SIGNAL(activated(int)), this, SLOT(onDirActivated(int)));
    connect(btnDirUp, SIGNAL(pressed()), this, SLOT(onDirUpPressed()));
    connect(cmbHistory, SIGNAL(activated(int)), this, SLOT(onHistoryActivated(int)));
    connect(btnAccept, SIGNAL(pressed()), this, SLOT(onAcceptPressed()));
    connect(this, SIGNAL(requestLists(QString, QString)), this->mTUIElement, SLOT(handleRequestLists(QString, QString)));
    connect(this, SIGNAL(filterChange(QString)), this->mTUIElement, SLOT(handleFilterUpdate(QString)));
    connect(this, SIGNAL(dirChange(QString)), this->mTUIElement, SLOT(handleDirChange(QString)));
    connect(this, SIGNAL(requestClients()), this->mTUIElement, SLOT(handleClientRequest()));
    connect(this, SIGNAL(locationChanged(QString)), this->mTUIElement, SLOT(handleLocationChange(QString)));
    connect(this, SIGNAL(requestLocalHome()), this->mTUIElement, SLOT(handleLocalHome()));
    connect(this, SIGNAL(reqDriveList()), this->mTUIElement, SLOT(handleReqDriveList()));
    connect(this, SIGNAL(fileSelected(QString, QString, bool)), this->mTUIElement, SLOT(sendSelectedFile(QString, QString, bool)));

    this->mLocationPath = "";
    this->mId = id;
    this->mFilename = new QStringList();
    mRCDialog = new Ui_RemoteClients();
    mRCDialog->setupUi(mRCDialog);
    this->mMode = FileBrowser::OPEN;

    QObject::connect(this->mRCDialog->buttonBox, SIGNAL(accepted()), this, SLOT(remoteClientsAccept()));
    QObject::connect(this->mRCDialog->buttonBox, SIGNAL(rejected()), this, SLOT(remoteClientsReject()));
    QObject::connect(this->mRCDialog->listWidget, SIGNAL(itemClicked(QListWidgetItem *)), this, SLOT(handleItemClicked(QListWidgetItem *)));
    emit dirChange(this->mLocationPath);
    // std::string tmp = this->mLocationPath.toStdString();
    //std::cerr << "FileBrowser: Path: " << tmp.c_str() << std::endl;
}
Esempio n. 4
0
void FileBrowser::remoteClientsAccept()
{
    this->mLocation = this->mRCDialog->mSelectedClient;
    this->mRCDialog->hide();
    QStringList temp = mLocation.split(" ");
    this->mLocation = temp.at(0);

    emit locationChanged(this->mLocation);
    emit dirChange(".");
}
Esempio n. 5
0
void FileBrowser::onHistoryActivated(int index)
{
    QString item = this->cmbHistory->itemText(index);
    this->cmbHistory->addItem(this->mLocationPath);
    this->mLocationPath = item;

    //std::string temp = this->mLocationPath.toStdString();
    //std::cerr << "FileBrowser::onHistoryActivated " <<  temp.c_str() << std::endl;
    emit dirChange(this->mLocationPath);
}
Esempio n. 6
0
void FileBrowser::onLstDirDoubleClick(QListWidgetItem *item)
{
    QString newDir = item->text();
    // Request Directory data from Data class for given Directory
    this->cmbHistory->addItem(this->mLocationPath);
    if (this->mLocationPath != "")
    {
        this->mLocationPath.append("/");
    }
    this->mLocationPath.append(newDir);

    //std::string temp = this->mLocationPath.toStdString();
    //std::cerr << "FileBrowser::onLstDirDoubleClick " <<  temp.c_str() << std::endl;
    emit dirChange(this->mLocationPath);
}
Esempio n. 7
0
void FileBrowser::onDirUpPressed()
{
    // go up one level of directories and request new lists
    // from Data class
    QDir locDir(this->mLocationPath);
    if (this->mLocation == "AccessGrid")
    {
        QStringList parts = this->mLocationPath.split("/");
        parts.removeLast();
        this->mLocationPath = parts.join("/");
    }
    else if (locDir.cdUp())
    {
        this->mLocationPath = locDir.path();
    }

    //std::string temp = this->mLocationPath.toStdString();
    //std::cerr << "FileBrowser::onDirUpPressed " <<  temp.c_str() << std::endl;
    emit dirChange(this->mLocationPath);
}
Esempio n. 8
0
int main(int argc, char * argv[], char **envp)
{
    //The following two functions catch and process the interrupt and stop signals
    //AKA signals sent by the Ctrl-C and Ctrl-Z commands
    if (signal(SIGINT,signal_catcher)==SIG_ERR)
    {
        perror("Sigset cannot set SIGINT");
        exit(SIGINT);
    }
    if (signal(SIGTSTP, signal_catcher)==SIG_ERR)
    {
        perror("Sigset can not set SIGTSTP");
        exit(SIGTSTP);
    }
    
    //Declaring and initializing variables to be used later
    initHistory();
    initAlias();
    int this_input = 0;
    
    char * input = (char *) malloc(sizeof(char)*64);
    strcpy (input, "noexit");
    char *shellname = (char *) malloc(sizeof(char)*32);
    strcpy (shellname, "myshell");
    
    setShellName(shellname);
    
    printf ("[%s]%% ", shellname);
    input = getLine(input, 100);
    
    //Making sure the program does not crash if the input simply the return key
    while (strcmp(input,"\0") == 0)
    {
        printf ("[%s]%% ", shellname);
        input = getLine(input, 100);
    }
    
    setHistory(input);
    breakLine (input);
    this_input = whichInput();
    
    char ** argrv = getargrv();
    int argrc = getargrc();
    
    int loop = 1;
    
    while (loop != 0)
    {
        //Loop and process commands until the exist command is entered
        if(this_input==4) {
            if(strcmp(argrv[argrc-1], "&")==0)
            {
                //printf("Before forking PID:%d\n", getpid());
                int pid = fork();
                if(pid==0)
                {
                    //sleep(2); //putting a delay in to emphasize background process
                    //printf("\nchild PID: %d\n", getpid());
                    decrargrc();
                    list();
                    //printf("\nIn the child process - ended.\n\n");
                    return 0;
                } else
                {
                    //printf("PPID:%d\n", getpid());
                    //printf("In the parent process.\n");
                    printf("%s process running in background", argrv[0]);
                }
            } else
                list();
            
        } else if(this_input==3) {
            if(strcmp(argrv[argrc-1], "&")==0)
            {
                int pid = fork();
                if(pid==0)
                {
                    decrargrc();
                    pwd();
                    return 0;
                } else
                    printf("%s process running in background", argrv[0]);
            } else
                pwd();
        } else if(this_input==6) {
            if(strcmp(argrv[argrc-1], "&")==0)
            {
                int pid = fork();
                if(pid==0)
                {
                    decrargrc();
                    prompt();
                    shellname = getShellName();
                    return 0;
                } else
                    printf("%s process running in background", argrv[0]);
            } else
            {
                prompt();
                shellname = getShellName();
            }
        } else if(this_input==2) {
            if(strcmp(argrv[argrc-1], "&")==0)
            {
                int pid = fork();
                if(pid==0)
                {
                    decrargrc();
                    dirChange();
                    return 0;
                } else
                    printf("%s process running in background", argrv[0]);
            } else
                dirChange();
        } else if(this_input==5) {
            if(strcmp(argrv[argrc-1], "&")==0)
            {
                int pid = fork();
                if(pid==0)
                {
                    decrargrc();
                    mypid();
                    return 0;
                } else
                    printf("%s process running in background", argrv[0]);
            } else
                mypid();
        } else if(this_input==1) {
            if (getargrc() == 1)
            {
                loop = 0;
                free (input);
                free (shellname);
                
                input = NULL;
                shellname = NULL;
                
                freeDynamicMem();
                return 0;
            } else {
                printf("%s: Arguments not valid.", argrv[0]);
            }
        } else if(this_input==7) {
            if(strcmp(argrv[argrc-1], "&")==0)
            {
                int pid = fork();
                if(pid==0)
                {
                    decrargrc();
                    printHistory();
                    return 0;
                } else
                    printf("%s process running in background", argrv[0]);
            } else
                printHistory();
        } else if(this_input==8) {
            if(strcmp(argrv[argrc-1], "&")==0)
            {
                int pid = fork();
                if(pid==0)
                {
                    printf("\n***I've put a 3 second delay in to emphasize this background process\n");
                    sleep(3); //putting a delay in to emphasize background proces
                    decrargrc();
                    printEnv(envp);
                    return 0;
                } else
                    printf("%s process running in background", argrv[0]);
            } else
                printEnv(envp);
        }else if(this_input==9) {
            if(strcmp(argrv[argrc-1], "&")==0)
            {
                int pid = fork();
                if(pid==0)
                {
                    decrargrc();
                    alias();
                    return 0;
                } else
                    printf("%s process running in background", argrv[0]);
            } else
                alias();
        }else if(this_input==10) {
            if(strcmp(argrv[argrc-1], "&")==0)
            {
                int pid = fork();
                if(pid==0)
                {
                    decrargrc();
                    murder();
                    return 0;
                } else
                    printf("%s process running in background", argrv[0]);
            } else
                murder();
        }else {
            nocmd(input);
        }
        printf ("\n[%s]%% ", shellname);
        input = getLine(input, 100);
        while (strcmp(input,"\0") == 0)
        {
            printf ("[%s]%% ", shellname);
            input = getLine(input, 100);
        }
        setHistory(input);
        breakLine (input);
        this_input = whichInput();
        argrv = getargrv();
        argrc = getargrc();
    }
    return 0;
}