Example #1
0
/*
  Display Help/Version
  returns true if application may exit
  TODO expand to all possible options
*/
static bool gm_display_help(int argc,char * argv[]) {
  for (int i=1;i<argc;i++){
    if ( (comparecase(argv[i],"--help")==0) || (comparecase(argv[i],"-h")==0) ) {
      fxmessage("Usage: %s [options]\n\n",FXPath::name(argv[0]).text());
      fxmessage("General options:\n"
                " -h, --help            Display this help page\n"
                " -v, --version         Display version information\n"
                "     --tray            Start minimized to tray\n"
#ifdef HAVE_OPENGL
                "     --disable-opengl  Disables opengl based features\n"
#endif
                "\n"
                "Control running music manager:\n"
                "     --play            Start playback\n"
                "     --play-pause      Toggle pause / playback.\n"
                "     --pause           Pause playback\n"
                "     --previous        Play previous track\n"
                "     --next            Play next track\n"
                "     --stop            Stop playback\n"
                "     --raise           Try to raise the main window\n"
                "     --toggle-shown    Show or Hide the main window\n"
                "     --now-playing     Show now playing notification\n"
                "\n"
                );
      return true;
      }
    else if ( (comparecase(argv[i],"--version")==0) || (comparecase(argv[i],"-v")==0) ) {
      fxmessage("Goggles Music Manager %s\n",APPLICATION_VERSION_STRING);
      return true;
      }
    }
  return false;
  }
Example #2
0
void GMSyncTask::update_tracks(FXint pathindex) {
  FXint nchanged=0;

  for (FXint i=0;i<ntracks;i++) {
    if (!tracks[i].url.empty()) nchanged++;
    }

  if (nchanged) {

    // Load existing tracks from database
    for (FXint i=0;i<ntracks;i++) {
      if (tracks[i].url.empty()) {
        database->getTrack(tracks[i].index,tracks[i]);
        tracks[i].url.clear();
        }
      }

    // Set track number based on import order
    if (options.track_from_filelist) {
      for (FXint i=0;i<ntracks;i++) {
        tracks[i].no=i+1;
        }
      }

    // Look for compilations
    if (options.detect_compilation)
      detect_compilation();


    // Update Database
    for (FXint i=0;i<ntracks;i++) {

      // Check for interrupts
      if (database->interrupt) {
        database->waitTask();
        }

      // Update or Insert
      if (tracks[i].index){
        fxmessage("update %d %s\n",tracks[i].index,tracks[i].url.text());
        dbtracks.update(tracks[i]);
        }
      else {
        fxmessage("insert %d %s\n",tracks[i].index,tracks[i].url.text());
        dbtracks.insert(tracks[i],pathindex);
        }

      // Update Progress
      count++;
      if (0==(count%100)) {
        taskmanager->setStatus(FXString::value("Syncing %d",count));
        }
      }
    changed=true;
    }
  ntracks=0;
  }
Example #3
0
/**
 * Application entry point.
 */
int main ( int argc, char **argv )
{
    for ( int i = 0;i < argc;i++ )
    {
        if ( !strcmp( argv[ i ], "-v" ) || !strcmp( argv[ i ], "--version" ) )
        {
            fxmessage( "\n%s\n", PACKAGE_STRING );
            return 0;
        }

        if ( !strcmp( argv[ i ], "-h" ) || !strcmp( argv[ i ], "--help" ) )
        {
            fxmessage( "\n-h, --help print this help\n" );
            fxmessage( "-v, --version print version\n" );
            return 0;
        }
    }

    string tmpdir = "/tmp/nao";
    if ( !FXFile::exists( tmpdir.c_str() ) )
    {
        FXFile::createDirectory( tmpdir.c_str(), 493 );
    }

    string dir = FXFile::getUserDirectory ( "" ).text ();
    dir = dir + "/.nao";
    string file = dir + "/nao.conf";

    if ( !FXFile::exists( file.c_str() ) )
    {
        FXFile::createDirectory( dir.c_str(), 493 );
        string dir2 = dir + "/icons";
        FXFile::createDirectory( dir2.c_str(), 493 );
        dir += "/plugins";
        FXFile::createDirectory( dir.c_str(), 493 );
        dir2 = dir + "/cmddialog";
        FXFile::createDirectory( dir2.c_str(), 493 );
        dir2 = dir + "/filelist";
        FXFile::createDirectory( dir2.c_str(), 493 );


        string src = PATH_CFG + string( "/nao.conf" );
        FXFile::copy( src.c_str(), file.c_str() );
    }
    fxTraceLevel = 0;
    FXApp *application = new FXApp ( "nao", NULL );
    application->init ( argc, argv );

    new OSMainWindow ( application );
    application->create ();
    return application->run ();
}
Example #4
0
void GMDBTracks::update(GMTrack & track) {

  /// Artist
  FXint album_artist_id = insertArtist(track.getAlbumArtist(default_artist));
  FXint artist_id       = insertArtist(track.getArtist(default_artist));
  FXint composer_id     = insertArtist(track.composer);
  FXint conductor_id    = insertArtist(track.conductor);
  FXint album_id        = insertAlbum(track,album_artist_id);

  /// Update Tracks
  update_track.set(0,track.title.empty() ? FXPath::title(track.url) : track.title);
  update_track.set(1,track.time);
  update_track.set(2,track.no);
  update_track.set(3,track.year);
  update_track.set(4,(track.sampleformat) ? -track.sampleformat : track.bitrate);
  update_track.set(5,track.samplerate);
  update_track.set(6,track.channels);
  update_track.set(7,track.filetype);
  update_track.set(8,album_id);
  update_track.set(9,artist_id);
  update_track.set_null(10,composer_id);
  update_track.set_null(11,conductor_id);
  update_track.set(12,FXThread::time());
  update_track.set(13,track.index);
  update_track.execute();

    fxmessage("%d %d\n",track.sampleformat,track.bitrate);

  /// Update Tags
  updateTags(track.index,track.tags);
  }
Example #5
0
void GMPlayListSource::save(GMTrackList* tracklist) {
  if (orderchanged) {
    fxmessage("saving state to db %d\n",orderchanged);
    GMPlayListItemList items;
    if (tracklist->getNumItems()) {
      items.no(tracklist->getNumItems());
      if (tracklist->getSortMethod()==HEADER_QUEUE){
        for (FXint i=0;i<tracklist->getNumItems();i++){
          const GMDBTrackItem * trk = dynamic_cast<GMDBTrackItem*>(tracklist->getItem(i));
          items[i].queue = trk->getTrackQueue();
          items[i].track = trk->getId();
          }
        }
      else {
        for (FXint i=0;i<tracklist->getNumItems();i++){
          const GMDBTrackItem * trk = dynamic_cast<GMDBTrackItem*>(tracklist->getItem(i));
          items[i].queue = i+1;
          items[i].track = trk->getId();
          }
        tracklist->setSortMethod(HEADER_QUEUE);
        }
      db->updatePlaylist(playlist,items);

      /// write back to database.
      orderchanged=false;
      }
    }
  }
Example #6
0
static void context_state_callback(pa_context *c,void*){
  fxmessage("[pulse] context_state_callback:");
  switch(pa_context_get_state(c)) {
    case PA_CONTEXT_UNCONNECTED : fxmessage(" unconnected\n"); break;
    case PA_CONTEXT_CONNECTING  : fxmessage(" connecting\n"); break;
    case PA_CONTEXT_AUTHORIZING : fxmessage(" authorizing\n"); break;
    case PA_CONTEXT_SETTING_NAME: fxmessage(" setting name\n"); break;
    case PA_CONTEXT_READY       : fxmessage(" ready\n"); break;
    case PA_CONTEXT_FAILED      : fxmessage(" failed\n"); break;
    case PA_CONTEXT_TERMINATED  : fxmessage(" terminated\n"); break;
    default                     : fxmessage(" unknown\n"); break;
    }
  }
Example #7
0
FXint GMRenameTask::run() {
  try {
    for (FXint i=0;i<from.no() && processing;i++) {
      if (to[i].empty()) continue;
      if (!FXDir::createDirectories(FXPath::directory(to[i]))) continue;
      if (FXStat::exists(to[i])) continue;
      fxmessage("Updating Filename %s\n",to[i].text());
      if (FXFile::moveFiles(from[i],to[i])){
        database->setTrackFilename(tracks[i],to[i]);
        }
      }
    }
  catch(GMDatabaseException&) {
    fxmessage("Database Error\n");
    }
  return 0;
  }
// Show and raise window, placed properly on the screen
void FXTransferManager::show(FXuint placement) {
    fxmessage("FXTransferManager::show(FXuint placement)\n");
    create();
    FXMainWindow::show(PLACEMENT_OWNER);
    getApp()->addTimeout(this,FXWindow::ID_SHOW,500);
    getApp()->refresh();
    transfer->start();
}
Example #9
0
File: main.cpp Project: ned14/tnfox
static void testcode(const char *msg, int a)
{
	for(int n=0; n<a; n++)
	{
		//QThread::sleep(1);
		fxmessage("%s counts to %d/%d\n", msg, n, a);
	}
}
Example #10
0
void GMPlayListSource::sorted(GMTrackList*tracklist,FXint method) {
  fxmessage("sort changed\n");
  if (orderchanged) {
    if (tracklist->getSortMethod()==HEADER_QUEUE && method!=HEADER_QUEUE) {
      save(tracklist);
      }
    }
  }
// Copy ordinary file
static FXbool copyfile (const FXString & oldfile, const FXString & newfile, thread_elem * te)
{
    unsigned char buffer[4096];
    struct stat status;
    long nread, nwritten;
    int src, dst;
    FXbool ok = FALSE;
    if ((src = open (oldfile.text (), O_RDONLY)) >= 0)
    {
	if (::stat (oldfile.text (), &status) == 0)
	{


	    te->act_file_name = oldfile.text ();
	    te->act_file_size = 1;
	    te->file_size = status.st_size;



	    if ((dst = open (newfile.text (), O_WRONLY | O_CREAT | O_TRUNC, status.st_mode)) >= 0)
	    {
		while (1)
		{
		    nread = fullread (src, buffer, sizeof (buffer));
		    if (nread < 0)
			goto err;
		    if (nread == 0)
			break;




		    if (te->cancel == true)
		    {
			fxmessage ("CANCEL CANCEL CANCEL CANCEL !!!\n\n\n\n\n");
			close (dst);
			close (src);
			return FALSE;
		    }

		    te->act_file_size += nread;
		    te->act_total_size += nread;



		    nwritten = fullwrite (dst, buffer, nread);
		    if (nwritten < 0)
			goto err;
		}
		ok = TRUE;
	      err:close (dst);
	    }
	}
	close (src);
    }
    return ok;
}
Example #12
0
static void stream_state_callback(pa_stream *s,void*){
  fxmessage("[pulse] stream_state_callback:");
  switch(pa_stream_get_state(s)) {
    case PA_STREAM_UNCONNECTED : fxmessage(" unconnected\n"); break;
    case PA_STREAM_CREATING    : fxmessage(" creating\n"); break;
    case PA_STREAM_READY       : fxmessage(" ready\n"); break;
    case PA_STREAM_FAILED      : fxmessage(" failed\n"); break;
    case PA_STREAM_TERMINATED  : fxmessage(" terminated\n"); break;
    default                     : fxmessage(" unknown\n"); break;
    }
  }
Example #13
0
/* Evaluate expression with arguments */
int main(int argc,char **argv){
  FXdouble parameter[10];
  FXExpression::Error err;
  FXExpression expr;
  FXdouble result;
  FXint i;
#ifndef NDEBUG
  fxTraceLevel=101;
#endif
  if(1<argc){
    fxmessage("evaluate(%s) :",argv[1]);
    err=expr.parse(argv[1],(2<argc)?argv[2]:NULL);
    if(err!=FXExpression::ErrOK){
      fxwarning(" Error: %s\n",FXExpression::getError(err));
      exit(1);
      }
    for(i=3; i<argc; i++){
      parameter[i-3]=strtod(argv[i],NULL);
      }
    result=expr.evaluate(parameter);
    fxmessage(" = %.17lg\n",result);
    }
  return 0;
  }
bool OSConfigure::loadconfig( bool restore )
{

    std::string dir = FXFile::getUserDirectory ( "" ).text ();
    file = dir + "/.nao/nao.conf";

    if ( !FXFile::exists ( file.c_str () ) )
    {
        file = "";
        file = file + PATH_CFG + SEPARATOR + "nao.conf";
    }
    FXTRACE ( ( 5, "OPENING CONFIGRATION FILE %s\n", file.c_str () ) );

    doc = xmlParseFile ( file.c_str () );
    copy = false;



    if ( !doc )
    {
        if ( restore )
        {
            fxmessage( "restore" );
            doc = xmlParseFile ( std::string( file + ".backup" ).c_str() );
            if ( doc )
                return true;
        }
        return false;
    }
    else
    {
        FXFile::copy( file.c_str(), std::string( file + ".backup" ).c_str(), true );
        return true;
    }

}
Example #15
0
long GMNotifyDaemon::onNotifyServer(FXObject*,FXSelector,void*ptr){
  DBusMessage * msg = static_cast<DBusMessage*>(ptr);
  const FXchar * dname=NULL;
  const FXchar * vendor=NULL;
  const FXchar * version=NULL;
  const FXchar * spec=NULL;

  if ((dbus_message_get_type(msg)==DBUS_MESSAGE_TYPE_METHOD_RETURN) && dbus_message_get_args(msg,NULL,DBUS_TYPE_STRING,&dname,DBUS_TYPE_STRING,&vendor,DBUS_TYPE_STRING,&version,DBUS_TYPE_STRING,&spec,DBUS_TYPE_INVALID)) {

    if (compareversion(spec,"1.1")==0) {
      icondata="image_data";
      }
    else if (compareversion(spec,"1.2")>=0) {
      icondata="image-data";
      }
    else {
      icondata="icon_data";
      }

    if (comparecase(vendor,"xfce")==0 && comparecase(dname,"xfce notify daemon")==0) {
      flags|=IMAGE_WITHOUT_APPICON;
      }

    if (comparecase(dname,"gnome-shell")==0 && comparecase(vendor,"gnome")==0) {
      GMPlayerManager::instance()->getPreferences().gui_tray_icon_disabled=true;
      flags|=ACTION_ITEMS;
      if (compareversion(version,"3.2.0")<0){
        flags|=IMAGE_WITHOUT_APPICON;
        }
      }
#ifdef DEBUG
    fxmessage("name: %s\n",dname);
    fxmessage("vendor: %s\n",vendor);
    fxmessage("version: %s\n",version);
    fxmessage("spec: %s\n",spec);
    fxmessage("icondata: %s\n",icondata.text());
    fxmessage("flags: %x\n",flags);
#endif
    }

  GMPlayerManager::instance()->update_tray_icon();
  return 1;
  }
Example #16
0
File: main.cpp Project: ned14/tnfox
int main(int argc, char *argv[])
{
	FXProcess myprocess(argc, argv);
	fxmessage("TnFOX Thread Pools test:\n"
		      "-=-=-=-=-=-=-=-=-=-=-=-=\n");
	fxmessage("Starting thread pool ...\n");
	QThreadPool &tp=FXProcess::threadPool();
	FXString txts[TOTAL];
	QThreadPool::handle handles[TOTAL];
	for(int n=0; n<TOTAL; n++)
	{
		txts[n]="No %1";
		txts[n].arg(n);
		fxmessage("Dispatching %s ...\n", txts[n].text());
		handles[n]=tp.dispatch(Generic::BindFuncN(testcode, txts[n].text(), 3));
	}
	for(int n=0; n<TOTAL; n++)
	{
		tp.wait(handles[n]);
	}

	fxmessage("\nNow testing timed jobs ...\n");
	for(int n=0; n<TOTAL; n++)
	{
		txts[n]="No %1";
		txts[n].arg(n);
		FXuint delay=fxrandom(seed) & 0xfff;
		fxmessage("Dispatching %s in %d msecs...\n", txts[n].text(), delay);
		handles[n]=tp.dispatch(Generic::BindFuncN(testcode, txts[n].text(), 3), delay);
	}
	for(int n=0; n<TOTAL; n++)
	{
		tp.wait(handles[n]);
	}

	fxmessage("All Done!\n");
#ifdef _MSC_VER
	if(!myprocess.isAutomatedTest())
		getchar();
#endif
	return 0;
}
long FXTransferManager::onProgress(FXObject*,FXSelector,void*) {
    bool addtimeout=false;
    FXint timeout=0;
    FXint response;
    FXTransferStatus progress;
    transfer->status(progress);

    if (getApp()->hasTimeout(this,FXWindow::ID_SHOW)) {
        timeout = getApp()->remainingTimeout(this,FXWindow::ID_SHOW);
        getApp()->removeTimeout(this,FXWindow::ID_SHOW);
        addtimeout=true;
    }

    switch(progress.code) {
    case STATUS_DONE:
        transfer->join();
        getApp()->stopModal(this,FALSE);
        hide();
        fxmessage("Joining...\n");
        close(FALSE);
        break;
    case STATUS_FATAL:
        transfer->join();
        FXMessageBox::error(this,MBOX_OK,"Fatal Error","%s",progress.error.text());
        //getApp()->stopModal(this,FALSE);
        hide();
        close(FALSE);
        break;
    case STATUS_OVERWRITE:
        response = FXMessageBox::question(this,MBOX_YES_NO_CANCEL,"Overwrite File?","File already exists. Overwrite?\nCopying file: %s\nto:%s",progress.srcfile.text(),progress.dstfile.text());
        if (response==MBOX_CLICKED_CANCEL) {
            transfer->respondOverwrite(FALSE,MAYBE,TRUE);
            transfer->join();
            //getApp()->stopModal(this,FALSE);
            hide();
            close(FALSE);
        }
        else if (response==MBOX_CLICKED_YES) {
            transfer->respondOverwrite(TRUE,MAYBE,FALSE);
            if (addtimeout)
                getApp()->addTimeout(this,FXWindow::ID_SHOW,timeout);
        }
        else {
            transfer->respondOverwrite(FALSE,MAYBE,FALSE);
            if (addtimeout)
                getApp()->addTimeout(this,FXWindow::ID_SHOW,timeout);
        }
        break;
    case STATUS_DELETE:
        response = FXMessageBox::question(this,MBOX_YES_NO,"Error Deleting File","Unable to remove file:\n%s\nContinue deleting remaining files?",progress.srcfile.text());
        if (response==MBOX_CLICKED_NO) {
            transfer->respondDelete(FALSE);
            transfer->join();
            //getApp()->stopModal(this,FALSE);
            hide();
            close(FALSE);
        }
        else {
            transfer->respondDelete(TRUE);
            if (addtimeout)
                getApp()->addTimeout(this,FXWindow::ID_SHOW,timeout);
        }
        break;
    default:
        text_count->setText(FXStringVal(progress.num));
        text_file->setText(progress.srcfile);
        if (progress_bar) {
            progress_bar->setTotal(progress.total);
            progress_bar->setProgress(progress.current);
        }
        if (addtimeout)
            getApp()->addTimeout(this,FXWindow::ID_SHOW,timeout);
        break;
    }
    return 1;
}
FXTransferManager::~FXTransferManager() {
    fxmessage("FXTransferManager::~FXTransferManager()\n");
    getApp()->removeTimeout(this,FXWindow::ID_SHOW);
    delete transfer;
    delete titlefont;
}