예제 #1
0
    MPRIS2::MPRIS2(QObject *parent) :
        QObject(parent)
    {

        AppName = "Player";
        new MediaPlayer2Adaptor(this);
        connect(this,SIGNAL(RaiseMainWindow()), this, SLOT(signalReceived()) );
        connect(this,SIGNAL(quitActivated()), this, SLOT(signalReceived()) );

    }
예제 #2
0
int main(int argc, char ** argv) {
	QCoreApplication app(argc, argv);

	ThreadCheck t;
	QObject::connect(&t, SIGNAL(signalReceived()), &t, SLOT(slotReceived()));
	t.start();

    // while(1);	// Need to allow execution of app.exec()!
	app.exec();
}
예제 #3
0
void ThreadCheck::run() {
	qDebug() << "Thread running.";
	 while(1)
     {
         mutex.lock();
         /*
          do some stuff
         */
		 sleep(1);

         mutex.unlock();
         emit signalReceived();
     }
}
예제 #4
0
void Widget::startServer()
{
	#ifdef WIN32
		//Initialize WINSOCK because CFTPServer needs it on Windows
		
		WSADATA WSAData;
		if( WSAStartup( MAKEWORD(1, 0), &WSAData) != 0 ) {
			//printf("-WSAStartup failure: WSAGetLastError=%d\r\n", WSAGetLastError() );
			QMessageBox::information(0, "Error", "Winsock error: " + WSAGetLastError());
			 //return 0;
		}
	#endif

	QString dir = qApp->applicationDirPath();

	if(QDir().exists("/Sync") == false)
	{
		QDir().mkdir(dir + "/Sync");
	}
	
	//Begin FTP Server Initialization
	ftpServer = new CFtpServer();
	ftpServer->SetDataPortRange(100, 900);

	CFtpServer::CUserEntry *FtpUser = ftpServer->AddUser("lanclient", "tseug", QString(dir + "/Sync").toAscii());
	ftpServer->AddUser("anonymous", NULL, "C:\\dir");

	if(FtpUser)
	{
		FtpUser->SetMaxNumberOfClient( 0 );
		FtpUser->SetPrivileges( CFtpServer::READFILE | CFtpServer::WRITEFILE |
								CFtpServer::LIST | CFtpServer::DELETEFILE | CFtpServer::CREATEDIR |
								CFtpServer::DELETEDIR );
	}
	else
	{
		writeLog("FTP Server Could Not Create User");
		sysIcon->showMessage("FTP Error", "No user could be created on the FTP Server. Login Not Possible", QSystemTrayIcon::Critical, 10000 );
		error();
	}
	if(ftpServer->StartListening(INADDR_ANY, 21))
	{
	   if(ftpServer->StartAccepting() == false)
		{
			writeLog("FTP Server Could Not Begin Accepting on Port 21. Code corruption or incompatible dll");
			sysIcon->showMessage("FTP Error", "FTP Server Couldn't start accepting connections.", QSystemTrayIcon::Critical, 10000 );
			error();
		}
	}
	else
	{
		writeLog("FTP Server Could Not Start Listening On Port 21. Check WINSOCK. This application does not support concurrent instances.");
		sysIcon->showMessage("FTP Error", "FTP Server Couldn't Listen on port 21. It may be in use already.", QSystemTrayIcon::Critical, 10000 );
		error();
	}

	/*
	End FTP Server Initialization
	All Files in the applications working directory are now availible through FTP with user "lanclient" with pass "tseug"
	*/

	client->setEnabled(false);
	udpSocket->bind(QHostAddress::Any, standardUdpPort, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint);
	connect(udpSocket, SIGNAL(readyRead()), this, SLOT(signalReceived()));

	//resize the mainWindow because we need a bigger interface for server mode
	mainWindow->resize(600, 500);

	//create the tab-widget that we parent the sub-windows too
	computerManager = new QTabWidget(mainWindow);
	computerManager->setGeometry(5, 70, 590, 430);

	primaryStatus = new QWidget(computerManager);
	ftpWindow = new QWidget(computerManager);
	serverDownload = new QPushButton(ftpWindow);
	serverDownload->setGeometry(20, 355, 545, 45);

	QObject::connect(serverDownload, SIGNAL(clicked()), this, SLOT(serverDownloadStart()));

	computersConnected = 0;

	ftpFiles = new QTreeWidget(ftpWindow);
	ftpFiles->setGeometry(0, 0, 580, 350);

	fileModel = new QTreeWidgetItem(0);

	computerNames.append("Files");

	ftpFiles->setHeaderLabels(computerNames);

	computerManager->addTab(primaryStatus, "Network Status");
	computerManager->addTab(ftpWindow, "File Control");

	mapper = new QSignalMapper(this);
	
	computerTable = new QTreeWidget(primaryStatus);
	computerTable->setGeometry(0, 0, 580, 400);
	
	QTreeWidgetItem * compModel = new QTreeWidgetItem(0);
	compModel->setText(0, "Name");
	compModel->setText(1,"Bytes Total");
	compModel->setText(2, "Active");
	
	computerTable->setHeaderItem(compModel);
	computerTable->setColumnCount(3);
	computerTable->setColumnWidth(0, 150);
	computerTable->setColumnWidth(1, 120);
	computerTable->setColumnWidth(2, 305);
	computerTable->show();
	
	timer = new QTimer(this);
	connect(timer, SIGNAL(timeout()), this, SLOT(update()));

	fileWatcher = new QFileSystemWatcher(this);
	fileWatcher->addPath(dir + "/Sync");
	connect(fileWatcher, SIGNAL(directoryChanged(QString)), this, SLOT(sendUpdate()));

	timer->start(tcpCheckRate);

	computerManager->show();
	updateFileTable();
}