Example #1
0
void CServerVersionCommand::Execute ()
{
#if (VERSION_CHECKING != VC_NONE)
	if (ArgGets (2).IsNullOrEmpty())
#endif
		ServerPrintf ("This server is running CleanCode version "CLEANCODE_VERSION_PRINT" built on %s\n", CLEANCODE_VERSION_PRINT_ARGS, ConfigTimeString().CString());
#if (VERSION_CHECKING != VC_NONE)
	else
		CheckNewVersion ();
#endif
}
Example #2
0
/**
\fn	void InitVersion ()

\brief	Initialises the version system. 

\author	Paril
\date	25/05/2010
**/
void InitVersion ()
{
#if (VERSION_CHECKING != VC_NONE)
	ServerPrint ("Checking for new version...\n");

	if (!CFile::Exists(VERSION_PATH))
	{
		ServerPrint ("Version file non-existant, writing... ");
		WriteVersion ();
		ServerPrint ("done\n");
	}
	else
		VerifyVersionFile ();
	
	CheckNewVersion ();
#endif
}
Example #3
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent)
{
    setupUi(this);

    Finished_Init = false;
    AllowInit = false;
    PreBuf_timer = new QTimer;
    Update_timer= new QTimer;
    Ping_timer= new QTimer;
    Spectrum_timer = new QTimer;
    BufferStatusUpdate_timer= new QTimer;
    singleClickTimer=new QTimer;
    m_msgbox = NULL;
    isPlaying=false;
    syncLost=false;
    currentRadio=NULL;
    currentTrack="";
    dConnectionProgress=NULL;
    dDelConfirm=NULL;
    dShowHistory=NULL;
    netManager=NULL;
    currentRadioURL=-1;
    streamsErrLoop=false;
    pSpec=NULL;
    mMoving=false;
    savedVolume=0.5;
    isMuted=false;
    treeSelectionChanged=false;
    isRecording=false;
    newVersionAnimation=NULL;
    recButtonAnimation=NULL;
    isRootOperation=false;
#ifdef VISUALS
    isVisResized=false;
    isVisRendering=false;
    visWin=new VisWinCL(this);
    bigVis=false;
    bigVisRunning=false;
#endif

    initBitRate();
    initOggQualityMap();

    qDebug()<<"Cheking BASS version";
    if (HIWORD(BASS_GetVersion())!=BASSVERSION) {
        qDebug()<<"An incorrect version of BASS.DLL was loaded";
        QMessageBox::warning(this,QString("warning"),QString("An incorrect version of BASS.DLL was loaded"));
    }

    BASS_SetConfigPtr(BASS_CONFIG_NET_AGENT, (void*) _T(PLAYER_HTTPAGENT));


#ifdef Q_OS_WIN
    if (BASS_PluginLoad("bass_aac.dll",0)==0) {
        qDebug()<<"Unable to load bass_aac.ddl  BassError="<<BASS_ErrorGetCode();
    }
#elif Q_OS_LINUX
    if (BASS_PluginLoad("bass_aac.so",0)==0) {
        qDebug()<<"Unable to load bass_aac.ddl  BassError="<<BASS_ErrorGetCode();
    }
#endif


    QSettings tSettings(AppPath+CONFIG_FILENAME,QSettings::IniFormat);
    tSettings.setIniCodec("ISO 8859-1");
    Proxy=tSettings.value("proxy","").toString();
    ProxyPort=tSettings.value("proxyport","").toString();
    ProxyUser=tSettings.value("proxyuser","").toString();
    ProxyPass=tSettings.value("proxypass","").toString();
    visualPlugin=tSettings.value("visual",VIS_WIN_PLUG).toString();
    qDebug()<<"visualPlugin="<<visualPlugin;
    recPath=tSettings.value("recpath","").toString();
    recPath=recPath.replace("\\","\\\\");
#ifdef Q_OS_WIN
    if (recPath!="" && recPath.at(recPath.length()-1)!='\\')
        recPath=recPath+"\\";
#else
    if (recPath!="" && recPath.at(recPath.length()-1)!='/')
        recPath=recPath+"/";
#endif

    if (recPath=="") {
#ifdef Q_OS_WIN
        recPath=QDir::toNativeSeparators(QStandardPaths::standardLocations(QStandardPaths::MusicLocation).at(0)+"/");
#endif

#ifdef Q_OS_MAC
        recPath=AppPath.fromLatin1(argv[0]);
        recPath+="/";
#endif
    }

    qDebug()<<"Recording path ="<<recPath;

    if (Proxy!="") {
        qDebug()<<"Proxy="<<Proxy;
        QString tBassProxyStr=ProxyUser;
        if (ProxyPass!="")
            tBassProxyStr+=":"+ProxyPass;
        if (ProxyUser!="")
            tBassProxyStr+="@";
        tBassProxyStr+=Proxy+":"+ProxyPort;
        qDebug()<<"BASSProxy="<<tBassProxyStr;
        qDebug()<<"BASSProxy="<<tBassProxyStr.toLatin1().data();
        //strcpy(proxyStrChar,Proxy.toLatin1().data());
        BASS_SetConfigPtr(BASS_CONFIG_NET_PROXY,tBassProxyStr.toLatin1().data());
        //BASS_SetConfigPtr(BASS_CONFIG_NET_PROXY,&proxyStrChar);
    }
    else {
        BASS_SetConfigPtr(BASS_CONFIG_NET_PROXY, NULL);
    }

    //if( !InitVersion() ) ErrorMsgBox(_T("\n Error Setting up Version strings \n"));
    if( !InitBassErrorMap() ) ErrorMsgBox(_T("\n Error setting up Error Msgs \n"));
    if (!BASS_Init(-1,44100,0,NULL,NULL)) {
        ErrorMsgBox(_T("\nUnable to initialize BASS library\n"), 86, false);
        exit(86);
    }

    savedVolume=BASS_GetVolume();
    slVolume->setValue(savedVolume*slVolume->maximum());


#ifdef Q_OS_WIN
    // allocate ACM format buffer, using suggested buffer size
    acmformlen = BASS_Encode_GetACMFormat(0,NULL,0,NULL,0);
    acmform = (WAVEFORMATEX*)malloc(acmformlen);
    memset(acmform,0,acmformlen);
    acmduncil = (WAVEFORMATEX*)malloc(acmformlen);
    memset(acmduncil, 0, acmformlen);
    //
#endif

    connect(radioTree,SIGNAL(AddStationSig(QModelIndex,RadioCL*)),this,SLOT(AddStation(QModelIndex,RadioCL*)));
    connect(radioTree, SIGNAL(treeSelectionChanged(const QModelIndex &, const QModelIndex &)), this,
            SLOT(radioTreeSelectionChanges(const QModelIndex &, const QModelIndex &)));

    qDebug()<<"Connecting timers signals ";
    connect(PreBuf_timer, SIGNAL(timeout()), this, SLOT(prebufTimeout()));
    connect(Update_timer, SIGNAL(timeout()), this, SLOT(updateTimeout()));
    connect(Ping_timer, SIGNAL(timeout()),this, SLOT(pingRadio()));
    connect(Spectrum_timer, SIGNAL(timeout()), this, SLOT(specTimeout()));
    connect(BufferStatusUpdate_timer, SIGNAL(timeout()),this, SLOT(updateBufferStatus()));
    connect(singleClickTimer, SIGNAL(timeout()),this, SLOT(singleClickTimeout()));

    qDebug()<<"Connecting mgh signals";
    connect( &mgh, SIGNAL(SendUpdTrackInfo(QString)), this, SLOT(on_UpdTrackInfo(QString)) );
    connect( &mgh, SIGNAL(SendUpdRadioInfo(QString,QString,QString,QString)), this, SLOT(on_UpdRadioInfo(QString,QString,QString,QString)));
    connect( &mgh, SIGNAL(SendSyncLost()), this, SLOT(on_SyncLost()) );
    connect( &mgh, SIGNAL(SendPlaybackStarts()), this, SLOT(on_PlaybackStarts()) );
    connect( &mgh, SIGNAL(SendClickRecord()), this, SLOT(on_ClickRecord()) );

    qDebug()<<"Creating actions";
    createActions();
    qDebug()<<"Creating tray icon";
    createTrayIcon();

    qDebug()<<"Setting tray icon";
    setIcon(PLAYER_STATUS_INACTIVE);
    trayIcon->setVisible(true);
    trayIcon->show();
    setWindowTitle(QString(PLAYER_NAME)+" v"+RADIOLA_VERSION);

    qDebug()<<"Initializing spectrum image";
    specbuf = NULL;
    specmode = DEFAULT_SPEC_MODE; // spectrum mode
    specpos = 0; // spectrum mode (and marker pos for 2nd mode)
    pSpec = new QImage(SPECWIDTH, SPECHEIGHT, QImage::Format_Indexed8);
    // setup palette
    pSpec->setColor(0, qRgb(0,0,0));
    for(int a=1; a < 128; a++) {
        pSpec->setColor(a, qRgb(2*a, 256-2*a, 0));
    }
    for(int a=0; a < 32; a++) {
        pSpec->setColor(128+a, qRgb(0, 0, 8*a));
        pSpec->setColor(128+32+a, qRgb(8*a, 0, 255));
        pSpec->setColor(128+64+a, qRgb(255, 8*a, 8*(31-a)));
        //pSpec->setColor(128+64+a, qRgb(8*(31-a), 8*a, 8*a));
        pSpec->setColor(128+96+a, qRgb(255, 255, 8*a));
        //pSpec->setColor(128+96+a, qRgb(255, 255, 8*a));
    }
    pSpec->setColor(254, qRgb(112, 112, 255));
    pSpec->setColor(253, qRgb(255, 128, 128));
    pSpec->setColor(255, qRgb(212,208,200));    // background color
    // create the bitmap
    specbuf = (BYTE*)pSpec->bits();
    pSpec->fill(255);
    specButton->setSpec(pSpec);

    readSettings();

    qDebug()<<"Connecting tray signals ";
    connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
            this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason)));

    setupRadioTree();

    historyFile.setFileName(GetHistoryDir());

    if (!historyFile.open(QIODevice::ReadWrite | QIODevice::Append)) {
        qDebug()<<"Unable to open history file for write"<<historyFile.fileName();
        return;
    }

    StopPlayback();

    QIcon icon = QIcon(MAINWIN_ICON);
    setWindowIcon(icon);

    new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_S), this, SLOT(showSettings()));
    new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_E), this, SLOT(showRecPath()));
    new QShortcut(QKeySequence(Qt::Key_F1), this, SLOT(showHelp()));
    new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_H), this, SLOT(showHistory()));
#ifdef Q_OS_WIN
    new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_V), this, SLOT(showVisualization()));
#endif
    new QShortcut(QKeySequence(Qt::Key_Space), this, SLOT(on_pbPlay_clicked()));
    new QShortcut(QKeySequence(Qt::Key_MediaPlay), this, SLOT(on_pbPlay_clicked()));
    new QShortcut(QKeySequence(Qt::Key_Delete), this, SLOT(removeRow()));
    new QShortcut(QKeySequence(Qt::Key_Insert), this, SLOT(insertStation()));
    new QShortcut(QKeySequence(Qt::Key_Plus), this, SLOT(insertSubfolder()));

    QGraphicsDropShadowEffect* effect = new QGraphicsDropShadowEffect();
    effect->setBlurRadius(1); //Adjust accordingly
    effect->setOffset(3,3); //Adjust accordingly
    setShadow(bnShowHistory);
    setShadow(pbPlay);
    setShadow(pbRecord);
    setShadow(pbQuit);

    recButtonAnimation=new QMovie(":/images/rec_animation.gif");
    connect(recButtonAnimation,SIGNAL(frameChanged(int)),this,SLOT(setRecButtonIcon(int)));

    singleClickTimer->setInterval(QApplication::doubleClickInterval());
    singleClickTimer->setSingleShot(true);

    CheckNewVersion();

    netManager = new QNetworkAccessManager(this);
    if (Proxy!="") {
        netManager->setProxy(QNetworkProxy(QNetworkProxy::HttpProxy,Proxy,ProxyPort.toInt(),ProxyUser,ProxyPass));
    }
    connect(netManager, SIGNAL(finished(QNetworkReply*)),this, SLOT(pingReply(QNetworkReply*)));
}
Example #4
0
BOOL CFamiTrackerApp::InitInstance()
{
	// InitCommonControls() is required on Windows XP if an application
	// manifest specifies use of ComCtl32.dll version 6 or later to enable
	// visual styles.  Otherwise, any window creation will fail.
	InitCommonControls();
#ifdef SUPPORT_TRANSLATIONS
	LoadLocalization();
#endif
	CWinApp::InitInstance();

	TRACE("App: InitInstance\n");

	if (!AfxOleInit()) {
		TRACE("OLE initialization failed\n");
	}

	// Standard initialization
	// If you are not using these features and wish to reduce the size
	// of your final executable, you should remove from the following
	// the specific initialization routines you do not need
	// Change the registry key under which our settings are stored
	// TODO: You should modify this string to be something appropriate
	// such as the name of your company or organization
	SetRegistryKey(_T(""));
	LoadStdProfileSettings(MAX_RECENT_FILES);  // Load standard INI file options (including MRU)

	// Load program settings
	m_pSettings = CSettings::GetObject();
	m_pSettings->LoadSettings();

	// Parse command line for standard shell commands, DDE, file open + some custom ones
	CFTCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);

	if (CheckSingleInstance(cmdInfo))
		return FALSE;

	//who: added by Derek Andrews <*****@*****.**>
	//why: Load all custom exporter plugins on startup.
	
	TCHAR pathToPlugins[MAX_PATH];
	GetModuleFileName(NULL, pathToPlugins, MAX_PATH);
	PathRemoveFileSpec(pathToPlugins);
	PathAppend(pathToPlugins, _T("\\Plugins"));
	m_customExporters = new CCustomExporters( pathToPlugins );

	// Load custom accelerator
	m_pAccel = new CAccelerator();
	m_pAccel->LoadShortcuts(m_pSettings);
	m_pAccel->Setup();

	// Create the MIDI interface
	m_pMIDI = new CMIDI();

	// Create sound generator
	m_pSoundGenerator = new CSoundGen();

	// Create channel map
	m_pChannelMap = new CChannelMap();

	// Start sound generator thread, initially suspended
	if (!m_pSoundGenerator->CreateThread(CREATE_SUSPENDED)) {
		// If failed, restore and save default settings
		m_pSettings->DefaultSettings();
		m_pSettings->SaveSettings();
		// Show message and quit
		AfxMessageBox(IDS_START_ERROR, MB_ICONERROR);
		return FALSE;
	}

	// Check if the application is themed
	CheckAppThemed();

	// Register the application's document templates.  Document templates
	//  serve as the connection between documents, frame windows and views
	CDocTemplate0CC* pDocTemplate = new CDocTemplate0CC(		// // //
		IDR_MAINFRAME, 
		RUNTIME_CLASS(CFamiTrackerDoc), 
		RUNTIME_CLASS(CMainFrame), 
		RUNTIME_CLASS(CFamiTrackerView));

	if (!pDocTemplate)
		return FALSE;
	
	if (m_pDocManager == NULL)		// // //
		m_pDocManager = new CDocManager0CC { };
	m_pDocManager->AddDocTemplate(pDocTemplate);

	// Work-around to enable file type registration in windows vista/7
	if (IsWindowsVistaOrGreater()) {		// // //
		HKEY HKCU;
		long res_reg = ::RegOpenKey(HKEY_CURRENT_USER, _T("Software\\Classes"), &HKCU);
		if(res_reg == ERROR_SUCCESS)
			RegOverridePredefKey(HKEY_CLASSES_ROOT, HKCU);
	}

	// Enable DDE Execute open
	EnableShellOpen();

	// Skip this if in wip/beta mode
#if !defined(WIP) && !defined(_DEBUG)
	// Add shell options
	RegisterShellFileTypes();		// // //
	static const LPCTSTR FILE_ASSOC_NAME = _T("0CC-FamiTracker Module");
	AfxRegSetValue(HKEY_CLASSES_ROOT, "0CCFamiTracker.Document", REG_SZ, FILE_ASSOC_NAME, lstrlen(FILE_ASSOC_NAME) * sizeof(TCHAR));
	// Add an option to play files
	CString strPathName, strTemp, strFileTypeId;
	AfxGetModuleShortFileName(AfxGetInstanceHandle(), strPathName);
	CString strOpenCommandLine = strPathName;
	strOpenCommandLine += _T(" /play \"%1\"");
	if (pDocTemplate->GetDocString(strFileTypeId, CDocTemplate::regFileTypeId) && !strFileTypeId.IsEmpty()) {
		strTemp.Format(_T("%s\\shell\\play\\%s"), (LPCTSTR)strFileTypeId, _T("command"));
		AfxRegSetValue(HKEY_CLASSES_ROOT, strTemp, REG_SZ, strOpenCommandLine, lstrlen(strOpenCommandLine) * sizeof(TCHAR));
	}
#endif

	// Handle command line export
	if (cmdInfo.m_bExport) {
		CCommandLineExport exporter;
		exporter.CommandLineExport(cmdInfo.m_strFileName, cmdInfo.m_strExportFile, cmdInfo.m_strExportLogFile, cmdInfo.m_strExportDPCMFile);
		ExitProcess(0);
	}

	// Dispatch commands specified on the command line.  Will return FALSE if
	// app was launched with /RegServer, /Register, /Unregserver or /Unregister.
	if (!ProcessShellCommand(cmdInfo)) {
		if (cmdInfo.m_nShellCommand == CCommandLineInfo::AppUnregister) {
			// Also clear settings from registry when unregistering
			m_pSettings->DeleteSettings();
		}
		return FALSE;
	}

	// Move root key back to default
	if (IsWindowsVistaOrGreater()) {		// // //
		::RegOverridePredefKey(HKEY_CLASSES_ROOT, NULL);
	}

	// The one and only window has been initialized, so show and update it
	m_pMainWnd->ShowWindow(m_nCmdShow);
	m_pMainWnd->UpdateWindow();
	// call DragAcceptFiles only if there's a suffix
	//  In an SDI app, this should occur after ProcessShellCommand
	// Enable drag/drop open
	m_pMainWnd->DragAcceptFiles();
	
	// Initialize the sound interface, also resumes the thread
	if (!m_pSoundGenerator->InitializeSound(m_pMainWnd->m_hWnd)) {
		// If failed, restore and save default settings
		m_pSettings->DefaultSettings();
		m_pSettings->SaveSettings();
		// Quit program
		AfxMessageBox(IDS_START_ERROR, MB_ICONERROR);
		return FALSE;
	}
	
	// Initialize midi unit
	m_pMIDI->Init();
	
	if (cmdInfo.m_bPlay)
		theApp.StartPlayer(MODE_PLAY);

#ifdef EXPORT_TEST
	if (cmdInfo.m_bVerifyExport) {
		m_bExportTesting = true;
		VerifyExport(cmdInfo.m_strVerifyFile);
	}
	else {
		// Append menu option
		m_pMainWnd->GetMenu()->GetSubMenu(2)->AppendMenu(MF_SEPARATOR);
		m_pMainWnd->GetMenu()->GetSubMenu(2)->AppendMenu(MF_STRING, ID_MODULE_TEST_EXPORT, _T("Test exporter"));
	}
#endif

	// Save the main window handle
	RegisterSingleInstance();

#ifndef _DEBUG
	m_pMainWnd->GetMenu()->GetSubMenu(4)->RemoveMenu(ID_MODULE_CHANNELS, MF_BYCOMMAND);		// // //
#endif

	if (m_pSettings->General.bCheckVersion)		// // //
		CheckNewVersion(true);

	// Initialization is done
	TRACE("App: InitInstance done\n");

	return TRUE;
}