Exemple #1
0
bool Client::uploadNewFile() {
    //ASSERT : data.filetype == FILE_TYPE_NEW
    std::string filename = this->data.filename; //Entire path.
    //reader.open(filename ); //In mode.
    //Need to process file name.
    //TODO : PROCESS FILE NAME. ADD IT TO MY DATABASE.
    std::string filename_processed = processFileName(filename); //Processes the file name.

    conn.writeToSocket(filename_processed); //cout-ing the filename on server side works.
    std::string cont;
    conn.readFromSocket(cont);

    conn.writeToSocket_file( filename , NEW_FILE);

    conn.readFromSocket( cont );
    std::string t(CONTINUE);
    conn.writeToSocket(t);

    string version;
    conn.readFromSocket(version);
    int ver = atoi( version.c_str() );
    //need to add to file.
    this->addToFileLog(this->user.userID , filename_processed , filename , ver);

    conn.writeToSocket(t);
    this->getServerFiles_login();
    this->dropboxpage->updateServerFiles();
    return true;
}
void CSupLoginServiceProvider::ConstructL()
{
	__LOGSTR_TOFILE("CSupLoginServiceProvider::ConstructL() begins");

	// Form full path to credentials settings file
	RFs &fs = CCoeEnv::Static()->FsSession();

	TFileName privatePath;
	fs.PrivatePath(privatePath);
	TParse parser;
	TFileName processFileName(RProcess().FileName());
	User::LeaveIfError(parser.Set(KLoginProviderSettingsFilename, &privatePath, &processFileName));
	iSettingsFile = parser.FullName();

	// Read credentials from settings file
	ReadDataFromFileL();

	if (iMemberID && iUsername && iPassword)
		iLogged = ETrue;

	// Discover and retrieve description of the web service
	CSenXmlServiceDescription* serviceDesc = CSenXmlServiceDescription::NewLC( KServiceEndpointMemberId, KNullDesC8 );

	serviceDesc->SetFrameworkIdL(KDefaultBasicWebServicesFrameworkID);

	// Create connection to web service
	iConnection = CSenServiceConnection::NewL(*this, *serviceDesc);

	CleanupStack::PopAndDestroy(); // serviceDesc

	__LOGSTR_TOFILE("CSupLoginServiceProvider::ConstructL() ends");
}
void LoadChemStationDataDialog::loadSingleFile(const QModelIndex &index)
{
  QVariant var;
  bool ok;

  if (!index.isValid())
    return;

  var = m_finfoModel->data(m_finfoModel->index(index.row(), 0), Qt::DisplayRole);

  QString path = processFileName(var, ok);
  if (!ok)
    return;

  m_loadInfo = LoadInfo(LoadingMode::SINGLE_FILE, path);
  accept();
}
Exemple #4
0
bool Document::save()
{
	// Save progress
	m_daily_progress->save();

	if (m_filename.isEmpty() || !processFileName(m_filename)) {
		return saveAs();
	}

	// Write file to disk
	DocumentWatcher::instance()->pauseWatch(this);
	DocumentWriter writer;
	writer.setFileName(m_filename);
	writer.setType(m_filename.section(QLatin1Char('.'), -1));
	writer.setEncoding(m_encoding);
	writer.setWriteByteOrderMark(Preferences::instance().writeByteOrderMark());
	writer.setDocument(m_text->document());
	bool saved = writer.write();
	m_encoding = writer.encoding();
	if (saved) {
		m_cache_outdated = false;
		emit replaceCacheFile(this, m_filename);
	} else {
		cache();
	}
	DocumentWatcher::instance()->resumeWatch(this);

	if (!saved) {
		QMessageBox::critical(window(), tr("Sorry"), tr("Unable to save '%1'.").arg(QDir::toNativeSeparators(m_filename)));
		return false;
	}

	m_saved_wordcount = m_document_stats.wordCount();

	m_text->document()->setModified(false);
	return true;
}
void Tresenv::readOptions()
{
    EnvirBase::readOptions();
    
    cConfiguration *cfg = getConfig();
    
    // note: configname and runstoexec will possibly be overwritten
    // with the -c, -r command-line options in our setup() method
    opt_configname = cfg->getAsString(CFGID_CONFIG_NAME);
    opt_runstoexec = cfg->getAsString(CFGID_RUNS_TO_EXECUTE);
    
    opt_extrastack = (size_t) cfg->getAsDouble(CFGID_TRESENV_EXTRA_STACK);
    opt_outputfile = cfg->getAsFilename(CFGID_OUTPUT_FILE).c_str();
    
    if (!opt_outputfile.empty())
    {
        processFileName(opt_outputfile);
        ::printf("Tresenv: redirecting output to file `%s'...\n",opt_outputfile.c_str());
        FILE *out = fopen(opt_outputfile.c_str(), "w");
        if (!out)
            throw cRuntimeError("Cannot open output redirection file `%s'",opt_outputfile.c_str());
        fout = out;
    }
}
Exemple #6
0
/*
 * ProcessOKorDClick -- user clicked OK or double clicked on a file
 */
void ProcessOKorDClick( gui_window *gui, unsigned id  )
{
    process_rc  prc;
    int         sel;
    int         realsel;
    char        path[_MAX_PATH];
    char        *optr;
    char        *ptr;
    int         i;
    unsigned    focusid;
    dlg_info    *dlg = GUIGetExtra( gui );

    if( id == CTL_OK ) { /* hit enter or clicked ok */
        GUIGetFocus( gui, &focusid );
        switch( focusid ) {
        case CTL_DIR_LIST  :
            id = focusid;
            break;
        case CTL_FILE_LIST :
            ptr = GUIGetText( gui, CTL_FILE_LIST );
            GUISetText( gui, CTL_EDIT, ptr );
            GUIMemFree( ptr );
            break;
        }
    }
    switch( id ) {
    case CTL_FILE_LIST :
    case CTL_OK :
        prc = processFileName( gui );
        if( prc == PROCESS_TRUE ) {
            dlg->dialogRC = OFN_RC_FILE_SELECTED;
            GUICloseDialog( gui );
        } else if( prc == PROCESS_FAIL ) {
            dlg->dialogRC = OFN_RC_RUNTIME_ERROR;
            GUICloseDialog( gui );
        }
        break;
    case CTL_DIR_LIST :
        sel = GUIGetCurrSelect( gui, id );
#if defined( __UNIX__ ) || defined( __NETWARE__ )
        path[0] = FILE_SEP_CHAR;
        path[1] = 0;
#else
        path[0] = 0;
#endif
        realsel = 0;
        for( i=0;i<sel;i++ ) {
            ptr = GUIGetListItem( gui, id, i );
            if( ptr == NULL ) {
                return;
            }
            optr = ptr;
            while( *ptr == INDENT_CHAR ) {
                ptr++;
            }
            if( *ptr == '-' ) {
                strcat( path, ptr+1 );
                realsel++;
                if( i > 0 ) {
                    strcat( path, FILE_SEP );
                }
            } else {
                GUIMemFree( optr );
                break;
            }
            GUIMemFree( optr );
        }
        ptr = GUIGetListItem( gui, id, sel );
        if( ptr == NULL ) {
            return;
        }
        optr = ptr;
        while( *ptr == INDENT_CHAR ) {
            ptr++;
        }
        strcat( path, ptr+1 );
        GUIMemFree( optr );
        goToDir( gui, path );
        if( !initDialog( gui, NULL, NULL ) ) {
            dlg->dialogRC = OFN_RC_RUNTIME_ERROR;
            GUICloseDialog( gui );
        } else {
            GUISetCurrSelect( gui, id, realsel );
        }
        break;
   }

} /* ProcessOKorDClick */