Ejemplo n.º 1
0
static void requote(FXString&s)
{
  s.substitute("\\", "\\\\", true);
  s.substitute("\n", "\\n", true);
  s.substitute("\r", "\\r", true);
  s.substitute("\"", "\\\"", true);
}
Ejemplo n.º 2
0
bool BackupMgr::SaveBackup(SciDoc*sci)
{
  FXString savename;
  FXString untitled;
  untitled.format(FN_FMT, backupdir.text(), abs(getpid()), SciDocUtils::ID(sci));
  if (SciDocUtils::Filename(sci).empty()) {
    savename=untitled;
  } else {
    if (FXStat::isFile(untitled)) {
      RemoveBackup(untitled);
    }
#ifdef WIN32
    savename=SciDocUtils::Filename(sci).text();
    savename.substitute(':', '%', true);
    savename.prepend(backupdir.text());
#else
    savename.format("%s%s", backupdir.text(), SciDocUtils::Filename(sci).text());
#endif
  }
  if (MakePath(FXPath::directory(savename))) {
    if (SciDocUtils::SaveToFile(sci,savename.text(),false)) {
      SciDocUtils::NeedBackup(sci, false);
      return true;
    } else {
      lasterror=SciDocUtils::GetLastError(sci);
      ErrorMessage(_("Failed to save backup"), savename);
      return false;
    }
  } else {
    return false;
  }
}
Ejemplo n.º 3
0
static void gm_parse_asx(FXString & data,FXStringList & mrl) {
  ASXParser asx;


  /// FIXME replace with nifty regex
  data.substitute("&","&");

  if (asx.parse(data)) {
    mrl=asx.files;
    }
  }
Ejemplo n.º 4
0
void GMNotifyDaemon::notify_track_change(const GMTrack & track){
  FXString body = FXString::value(fxtrformat("%s\n%s (%d)"),track.artist.text(),track.album.text(),track.year);
  /// Dirty Hack. According to the spec, we shouldn't have to do this,
  /// but try finding a notification notifydaemon that actually implements it...
  /// http://www.galago-project.org/specs/notification/0.9/index.html
  body.substitute("&","&");

  FXImagePtr image;

  image = GMCover::copyToImage(GMPlayerManager::instance()->getCoverManager()->getCover(),64);

  notify(track.title.text(),body.text(),-1,image);
  }
Ejemplo n.º 5
0
void BackupMgr::RemoveBackup(SciDoc*sci)
{
  FXString untitled;
  SciDocUtils::NeedBackup(sci,false);
  untitled.format(FN_FMT, backupdir.text(), abs(getpid()), SciDocUtils::ID(sci));
  RemoveBackup(untitled);
  if (!SciDocUtils::Filename(sci).empty()) {
    FXString savename;
#ifdef WIN32
    savename=SciDocUtils::Filename(sci).text();
    savename.substitute(':', '%', true);
    savename.prepend(backupdir.text());
#else
    savename.format("%s%s", backupdir.text(), SciDocUtils::Filename(sci).text());
#endif
    RemoveBackup(savename);
  }
}
Ejemplo n.º 6
0
/** The text entered in the command textfield is sent (enter key pressed)
  *
  *
  * \param o A parameter used for FOX callbacks
  * \param s A parameter used for FOX callbacks
  * \param v The text comming from the command textfield
  *
  * \return Always 1
  *
  */
long RainbruRPG::Gui::FtpClientWindow::
treatNewCommand(FXObject* o,FXSelector s,void* v){
  FXString str;
  str=(FX::FXchar*)v;

  FXString filename=(FX::FXchar*)v;

  // If the entered text is not empty
  if (!str.empty()){

    fxText->appendText( "> " );
    fxText->appendText( str );
    fxText->appendText( "\n" );
    
    FXTextField* a=(FXTextField*)o;
    a->setText("");


    str=str.upper();
    if (str.contains("HELP")!=0){
      if (str.contains("USER")!=0){
	showHelpUser();
      }
      else if (str.contains("PASS")!=0){
	showHelpPass();
      }
      else if (str.contains("PASV")!=0){
	showHelpPasv();
      }
      else if (str.contains("PWD")!=0){
	showHelpPwd();
      }
      else if (str.contains("LIST")!=0){
	showHelpList();
      }
      else if (str.contains("SYST")!=0){
	showHelpSyst();
      }
      else if (str.contains("BINARY")!=0){
	showHelpBinary();
      }
      else if (str.contains("ASCII")!=0){
	showHelpAscii();
      }
      else if (str.contains("STOR")!=0){
	showHelpStore();
      }
      else if (str.contains("RETR")!=0){
	showHelpRetrieve();
      }
      else{
	onHelp(NULL,0,NULL);

      }
    }
    else if (str.contains("LIST")!=0){
      string s=ftpClient->commandLIST();
      FXString str=s.c_str();
      str.substitute('\r', ' ', true );
      logMessage(str);
    }
    else if (str.contains("PASV")!=0){
      ftpClient->toggleTransferMode();
      string s=ftpClient->waitControlResponse();
      logMessage(s.c_str());
    }
    else if (str.contains("PWD")!=0){
      string s=ftpClient->commandPWD();
      logMessage(s.c_str());
    }
    else if (str.contains("SYST")!=0){
      string s=ftpClient->commandSYST();
      logMessage(s.c_str());
    }
    else if (str.contains("BINARY")!=0){
      string s=ftpClient->commandBINARY();
      logMessage(s.c_str());
    }
    else if (str.contains("ASCII")!=0){
      string s=ftpClient->commandASCII();
      logMessage(s.c_str());
    }
    else if (str.contains("STOR")!=0){
      // because str is in UPPER case
      // I get the no-upper string
      int pos = str.find("STOR", 0);
      filename.erase( pos, 5 );

      LOGCATS("Filename :");
      LOGCATS(filename.text());
      LOGCAT();

      std::string fn(filename.text());

      // Get filename
      int filesize=ftpClient->getFilesize(fn);
      labTrPb->setTotal(filesize);

      // Change transfer information
      labTransName->setText(filename);
      labTransOrie->setText("Out");
      labTransSize->setText(filesizeToString(filesize));

      string s=ftpClient->commandSTOR(fn);
      logMessage(s.c_str());
    }
    else if (str.contains("RETR")!=0){
      // because str is in UPPER case
      // I get the no-upper string
      int pos = str.find("RETR", 0);
      filename.erase( pos, 5 );

      LOGCATS("Filename :");
      LOGCATS(filename.text());
      LOGCAT();

      std::string fn(filename.text());

      // Change transfer information
      labTransName->setText(filename);
      labTransOrie->setText("In");

      string s=ftpClient->commandRETR(fn);
      logMessage(s.c_str());
    }
    else{
      logMessage("Unknown command");
    }
  }

  scrollDown();
  return 1;
}
Ejemplo n.º 7
0
// Watch progress of child process
long CommandWindow::onWatchProcess(FXObject*, FXSelector, void*)
{
    char buf[1024];
    int  nread;

    if (closed)
    {
        // The close button was pressed : just close the pipes
        // and delete the object

        // Close pipes
        ::close(pipes[0]);
        ::close(pipes[1]);

        // Object deletes itself!
        delete this;
    }

    else if ((waitpid(pid, NULL, WNOHANG) == 0))
    {
        // Child is still running, just wait
        getApp()->addChore(this, ID_WATCHPROCESS);

        // Read data from the running child (first, set I-O to non-blocking)
        int pflags;
        if ((pflags = fcntl(pipes[0], F_GETFL)) >= 0)
        {
            pflags |= O_NONBLOCK;
            if (fcntl(pipes[0], F_SETFL, pflags) >= 0)
            {
                // Now read the data from the pipe
                while ((nread = read(pipes[0], buf, sizeof(buf)-1)) > 0)
                {
                    buf[nread] = '\0';
                    // Remove backspace characters, if any
                    FXString strbuf = buf;
                    strbuf = strbuf.substitute("\b", ".");
                    text->appendText(strbuf.text(), strlen(strbuf.text()));
                    scrollToLastLine();
                    if (nread < (int)(sizeof(buf)-1))
                    {
                        break;
                    }
                }
            }
        }
    }

    else
    {
        // Child has finished.
        // Read data from the finished child
        while ((nread = read(pipes[0], buf, sizeof(buf)-1)) > 0)
        {
            buf[nread] = '\0';
            // Remove backspace characters, if any
            FXString strbuf = buf;
            strbuf = strbuf.substitute("\b", ".");
            text->appendText(strbuf.text(), strlen(strbuf.text()));
            scrollToLastLine();
            if (nread < (int)(sizeof(buf)-1))
            {
                break;
            }
        }
        if (killed)
        {
            appendText(_("\n>>>> COMMAND CANCELLED <<<<"));
        }
        else
        {
            appendText(_("\n>>>> END OF COMMAND <<<<"));
        }
        scrollToLastLine();

        // Close pipes
        ::close(pipes[0]);
        ::close(pipes[1]);
    }


    return(1);
}