Esempio n. 1
0
void
WVDialer::checkOldConfiguration()
{
  QString filename = QDir::homeDirPath();
  filename += "/.qtwvdialer";
  
  // Check if configuration file is from version < 0.3
  // if so create the new configuration directory and
  // move the file
  //
  QFile file( filename );
  if (file.exists())
  {
    QFileInfo fi( filename );
  
    if (fi.isFile())
    {
      SimpleCfg tmpCfg( filename );
      file.remove();
      
      QDir dir = QDir::home();
      dir.mkdir( ".qtwvdialer" );
      filename = QDir::homeDirPath();
      filename += "/.qtwvdialer/settings";
      tmpCfg.setFilename( filename );
      tmpCfg.save();
      dir.cd( ".qtwvdialer" );
      dir.mkdir( "logs" );
      QMessageBox::information( this, 
          tr( "QtWvDialer moved old configuration" ),
          tr( "QtWvDialer has created the directory .qtwvdialer in your"
              " home directory.<p>Here you'll find the settings of QtWvDialer"
              " and the monthly logfiles. The old configuration file" 
              " <i>(QtWvDialer version &lt; 0.3)</i> ~/.qtwvdialer can be found"
              " now at ~/.qtwvdialer/settings" ) );
    }
  }
  else
  {
    // create configuration directory 
    //
    QDir dir = QDir::home();
    dir.mkdir( ".qtwvdialer" );
    dir.cd( ".qtwvdialer" );
    dir.mkdir( "logs" );
    
    QMessageBox::information( this,
          tr( "QtWvDialer created configuration" ),
          tr( "QtWvDialer has created the directory .qtwvdialer in your"
              " home directory.<p>Here you'll find the settings of QtWvDialer"
              " and the monthly logfiles <i>(if enabled)</i>" ) );
  }
}
Esempio n. 2
0
//load the contents of a file, line by line, into a global vector<string>
bool loadfile(string sfile)
{
	ifstream tmpCfg(sfile);
	string stemp;//buffer for getline()
	if (tmpCfg.fail())
	{
		return false;
	}
	while (getline(tmpCfg, stemp))
	{
		if (!stemp.empty())
		{
			Currentvsfile.push_back(stemp);
		}
	}
	// done reading file
	tmpCfg.close();
	return true;
}