Application::Application()
    : mTransferWindow(&mTransferModel),
#ifdef BUILD_APPINDICATOR
      mIcon(Platform::useIndicator() ? static_cast<Icon*>(new IndicatorIcon) :
                                       static_cast<Icon*>(new TrayIcon)),
#else
      mIcon(new TrayIcon),
#endif
      mStartTime(QDateTime::currentMSecsSinceEpoch())
{
    connect(&mDeviceModel, &DeviceModel::rowsInserted, this, &Application::notifyDevicesAdded);
    connect(&mDeviceModel, &DeviceModel::rowsAboutToBeRemoved, this, &Application::notifyDevicesRemoved);
    connect(&mTransferModel, &TransferModel::dataChanged, this, &Application::notifyTransfersChanged);
    connect(&mTransferServer, &TransferServer::error, this, &Application::notifyError);
    connect(&mTransferServer, &TransferServer::newTransfer, &mTransferModel, &TransferModel::addReceiver);

#ifdef BUILD_UPDATE_CHECKER
    connect(&mUpdateChecker, &UpdateChecker::newVersion, this, &Application::notifyNewVersion);
#endif

    mIcon->addAction(tr("Send Files..."), this, SLOT(sendFiles()));
    mIcon->addAction(tr("Send Directory..."), this, SLOT(sendDirectory()));
    mIcon->addSeparator();
    mIcon->addAction(tr("View Transfers..."), &mTransferWindow, SLOT(show()));
    mIcon->addSeparator();
    mIcon->addAction(tr("Settings"), this, SLOT(onOpenSettings()));
    mIcon->addSeparator();
    mIcon->addAction(tr("About..."), this, SLOT(onOpenAbout()));
    mIcon->addAction(tr("About Qt..."), this, SLOT(onOpenAboutQt()));
    mIcon->addSeparator();
    mIcon->addAction(tr("Exit"), QApplication::instance(), SLOT(quit()));

    // Start the transfer server
    mTransferServer.start();
}
void FileSendProgressDialog::initialise()
{
    connect(m_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(error(QAbstractSocket::SocketError)));
    connect(m_socket, SIGNAL(bytesWritten(qint64)), this, SLOT(updateStatus(qint64)));
    //connect(m_socket, SIGNAL(connected()), this, SLOT(sendFiles()));
    connect(m_socket, SIGNAL(readyRead()), this, SLOT(nextFileRequested()));
    connect(m_socket, SIGNAL(disconnected()), this, SLOT(accept()));
    connect(m_socket, SIGNAL(disconnected()), m_socket, SLOT(deleteLater()));
    connect(this, SIGNAL(attemptSend()), this, SLOT(sendFiles()));
    connect(this, SIGNAL(canceled()), this, SLOT(reject()));
}
Exemplo n.º 3
0
int sync_(int *socket,char **buffer)
{
    printf("Sync with server has started.\n");
    if(sendFileList(socket))
    {
        memset(*buffer,0,BUFFER_SIZE);
        int buffer_size = BUFFER_SIZE;
        if(recvRequests(socket,buffer,&buffer_size))
            if(sendFiles(socket,*buffer))
                return 1;
    }
    return 0;
}
Exemplo n.º 4
0
void FolderSource::start() {
	running = true;
	sendFiles();
}
Exemplo n.º 5
0
/* -------------------------------------------------------------------- */
BOOL dc15network(BOOL master)
{
    char line[100], line2[100];
    label here, there;
    FILE *file;
    int i, rms;
    time_t t, t2=0;
    BOOL    done = FALSE;
    
    netFailed = FALSE;
    
    if (!gotCarrier()) return FALSE;

    sprintf(line, "%s\\mesg.tmp", cfg.temppath);
    unlink(line);
    
    sprintf(line, "%s\\mailin.tmp", cfg.temppath);
    unlink(line);

    sprintf(line, "%s\\roomreq.in", cfg.temppath);
    unlink(line);
    
    sprintf(line, "%s\\roomreq.out", cfg.temppath);
    unlink(line);

    if((file = fopen(line, "ab")) == NULL)
    {
        perror("Error opening roomreq.out");
        return FALSE;
    }

    for (i=get_first_room(here, there), rms=0;
         i;
         i=get_next_room(here, there), rms++)
    {
        PutStr(file, there);
    }

    PutStr(file, "");
    fclose(file);

    if (master)
    {
        sendRequest();
        if (!gotCarrier()) return FALSE;
        reciveRequest();
    }
    else
    {
        reciveRequest();
        if (!gotCarrier()) return FALSE;
        sendRequest();
    }
    
    if (!gotCarrier() || netFailed) return FALSE;
    
    if (master)
    {
        /* clear the buffer */
        while (gotCarrier() && MIReady())
        {
            getMod();
        }
    }
    
    makeSendFile();
    
    if (!gotCarrier() || netFailed) return FALSE;
        
    /*
     * wait for them to get their shit together 
     */
    cPrintf(" Waiting for transfer.");
    
    outMod('X');
    t2 = 0;
    t = time(NULL); 
    while (gotCarrier() && !done)
    {
        if (time(NULL) > (t + (35 * 60))) /* only wait 35 minutes */
        {
            drop_dtr();
            netFailed = TRUE;
        }
        
        if (MIReady())
        {
            i = getMod();
            if (i == 'X' || node.network != NET_DCIT16)
            {
                done = TRUE;
            }
            else
            {
                if (debug)
                {
                    cPrintf("<%c>", i);
                }
            }
                
        }
        
        /* wake them up! (every second) */
        if (time(NULL) != t2)
        {
            outMod('X');
            t2 = time(NULL);
        }
    }
    
    /* wake them up! */
    for (i=0; i<10; i++)
        outMod('X');
    
    doccr();

    if (!gotCarrier() || netFailed) return FALSE;

    if (master)
    {
        reciveFiles();
        if (!gotCarrier() || netFailed) return FALSE;
        sendFiles();
    }
    else
    {
        sendFiles();
        if (!gotCarrier() || netFailed) return FALSE;
        reciveFiles();
    }
    
    if (netFailed) return FALSE;
    
    cPrintf(" Hangup.");
    doccr();
    
    drop_dtr();

    cPrintf(" Uncompressing message files.");
    doccr();
         
    sformat(line, node.unzip, "d", roomdatain);
    apsystem(line);
         
    unlink(roomdatain);
    
    for (i=0; i<rms; i++)
    {
        sprintf(line,  "room.%d",   i);
        sprintf(line2, "roomin.%d", i);
        rename(line, line2);
    }
        
    sprintf(line,  "%s\\mesg.tmp",   cfg.temppath);
    sprintf(line2, "%s\\mailin.tmp", cfg.temppath);
    rename(line, line2);

    return TRUE;
}
Exemplo n.º 6
0
void MainWindow::initial()
{
    my_sync_widget->setWindowModality(Qt::WindowModal);
    my_sync_widget->hide();

    connect(my_sync_widget, SIGNAL(getSaveFile(QString&)), this, SLOT(syncSaveFile(QString&)));
    connect(my_sync_widget, SIGNAL(enableServiceButton(QString&)), this, SLOT(serviceAdded(QString&)));
    connect(this, SIGNAL(syncClickEmit()), my_sync_widget, SLOT(syncFiles()));
    connect(my_sync_widget, SIGNAL(openXml(QString&)), this, SLOT(openXmlRecv(QString&)));

    connect(my_sync_widget, SIGNAL(dboxAuthResult(bool)), this, SLOT(dboxAuthStatus(bool)));
    connect(my_sync_widget, SIGNAL(dboxRecvResult(bool)), this, SLOT(dboxRecvStatus(bool)));
    connect(my_sync_widget, SIGNAL(dboxSendResult(bool)), this, SLOT(dboxSendStatus(bool)));

    connect(my_sync_widget, SIGNAL(googleAuthResult(bool)), this, SLOT(googleAuthStatus(bool)));
    connect(my_sync_widget, SIGNAL(googleRecvResult(bool)), this, SLOT(googleRecvStatus(bool)));
    connect(my_sync_widget, SIGNAL(googleSendResult(bool)), this, SLOT(googleSendStatus(bool)));

    fileMenu = menuBar()->addMenu(tr("&File"));

    newList = new QAction( tr("&New lists..."), this );
    newList->setShortcuts(QKeySequence::New);
    fileMenu->addAction(newList);
    connect(newList, SIGNAL(triggered()),
            this->my_task_list,SLOT(new_list()));

    fileMenu->addSeparator();
    loadAction = new QAction(tr("&Open XML..."), this);
    loadAction->setShortcuts(QKeySequence::Open);
    fileMenu->addAction(loadAction);
    connect(loadAction, SIGNAL(triggered()),
            this, SLOT(loadFile()));

    saveAction = new QAction( tr("&Save..."), this );
    saveAction->setShortcuts(QKeySequence::Save);
    fileMenu->addAction(saveAction);
    connect(saveAction, SIGNAL(triggered()),
            this, SLOT(saveFile()));

    saveAsAction = new QAction( tr("&Save as..."), this );
    //saveAsAction->setShortcuts(QKeySequence::SaveAs);
    fileMenu->addAction(saveAsAction);
    connect(saveAsAction, SIGNAL(triggered()),
            this, SLOT(saveasFile()));

    fileMenu->addSeparator();


    printAction = new QAction(tr("&Print"),this);
    printAction->setShortcuts(QKeySequence::Print);
    fileMenu->addAction(printAction);
    connect(printAction, SIGNAL(triggered()),
            this,SLOT(print()));

    fileMenu->addSeparator();

    exitAction = new QAction(tr("&Exit"), this);
    fileMenu->addAction(exitAction);
    connect(exitAction, SIGNAL(triggered()),
            this, SLOT(close()));

    OptMenu = menuBar()->addMenu(tr("&Options"));

    change_font = new QAction(tr("&Change Font"),this);
    OptMenu->addAction(change_font);

    display_note = new QAction(tr("&Display/Hide Note"), this);
    OptMenu->addAction(display_note);

    search_for= new QAction(tr("&Search"),this);
    search_for->setShortcut(QKeySequence::Find);
    OptMenu->addAction(search_for);
    connect(search_for,SIGNAL(triggered()),this,SLOT(search_start()));

    Template = menuBar()->addMenu(tr("&Template"));

    new_grocery = new QAction(tr("&Groceries"),this);
    Template->addAction(new_grocery);

    new_week_task = new QAction(tr("&Weekly Task"),this);
    Template->addAction(new_week_task);


    Sync = menuBar()->addMenu(tr("&Sync Menu"));

    new_service = new QAction(tr("&Add Service"), this);
    Sync->addAction(new_service);
    sync_service = new QAction(tr("&Sync Services (On)"), this);
    Sync->addAction(sync_service);
    sync_service_off = new QAction(tr("&Sync Services Off"), this);
    Sync->addAction(sync_service_off);
    send_service = new QAction(tr("&Send Current File"), this);
    Sync->addAction(send_service);
    get_service = new QAction(tr("&Get Dropbox Files"), this);
    Sync->addAction(get_service);
    send_service_gtask = new QAction(tr("&Send Current File (GTask)"), this);
    Sync->addAction(send_service_gtask);
    get_service_gtask = new QAction(tr("&Get GTask Files"), this);
    Sync->addAction(get_service_gtask);

    sync_service->setDisabled(true);
    send_service->setDisabled(true);
    sync_service_off->setDisabled(true);
    get_service->setDisabled(true);
    send_service_gtask->setDisabled(true);
    get_service_gtask->setDisabled(true);

    addTask = new QPushButton( tr("Add Task") );
    delTask = new QPushButton( tr("Delete") );
    editTask = new QPushButton( tr("Edit Task") );
    pop_up = new QPushButton(tr("Pop Task Up"));
    move_down = new QPushButton(tr("Move Task Down"));
    search_button = new QPushButton(tr("Search"));

    QWidget *main_widget = new QWidget;

    QVBoxLayout *main_layout = new QVBoxLayout;
    QHBoxLayout *button_layout1 = new QHBoxLayout;
    QHBoxLayout *button_layout2 = new QHBoxLayout;

    //here is the list name area
    //main_layout->addWidget( new QLabel(tr("Lists name")),0,Qt::AlignCenter );
    //main_layout->addWidget(my_task_list->lists_name);


    this->my_task_list->setColumnCount(5);
    QStringList tmp_l;
    tmp_l << "Name" << "Note" << "Tag" << "Due Date" << "Status";
    this->my_task_list->setHeaderLabels(tmp_l );

    this->my_task_list->setEditTriggers(QAbstractItemView::DoubleClicked);
    this->my_task_list->setSelectionMode(QAbstractItemView::SingleSelection);
    this->my_task_list->setSelectionBehavior(QAbstractItemView::SelectRows);
    //here is the table content
    /*QStandardItemModel *tmp_mod = my_task_list->mod;
    tmp_mod->setColumnCount(4);
    tmp_mod->setHeaderData(0, Qt::Horizontal, tr("Name"));
    tmp_mod->setHeaderData(1,Qt::Horizontal, tr("Note"));
    tmp_mod->setHeaderData(2,Qt::Horizontal, tr("Due date"));
    tmp_mod->setHeaderData(3,Qt::Horizontal, tr("Status"));
    my_task_list->table->setModel(tmp_mod);
    my_task_list->table->setEditTriggers(QAbstractItemView::DoubleClicked);
    my_task_list->table->setSelectionMode(QAbstractItemView::SingleSelection);
    my_task_list->table->setSelectionBehavior(QAbstractItemView::SelectRows);*/

    /*QTreeWidgetItem* task_child = new QTreeWidgetItem(this->my_task_list,0);
    task_child->setText(0,"a");
    this->my_task_list->addTopLevelItem(task_child);
    QTreeWidgetItem* task_child1 = new QTreeWidgetItem(task_child,1);
    task_child1->setText(0,"1");
    QTreeWidgetItem* task_child2 = new QTreeWidgetItem(task_child,1);
    task_child2->setText(0,"2");
    QTreeWidgetItem* task_child3 = new QTreeWidgetItem(task_child,1);
    task_child3->setText(0,"3");
    task_child->addChild(task_child1);
        task_child->addChild(task_child2);
            task_child->addChild(task_child3);
            QTreeWidgetItem* task_child4 = new QTreeWidgetItem(task_child,1);
            task_child4->setText(0,"0");
            task_child->insertChild(-2,task_child4);
    */


    main_layout->addWidget( new QLabel(tr("Current Lists")),0,Qt::AlignCenter );
    main_layout->addWidget(this->my_task_list);

    button_layout1->addWidget(addTask);
    button_layout1->addWidget(delTask);
    button_layout1->addWidget(editTask);

    button_layout2->addWidget(pop_up);
    button_layout2->addWidget(move_down);
    button_layout2->addWidget(search_button);

    main_layout->addLayout(button_layout1);
    main_layout->addLayout(button_layout2);
    main_widget->setLayout(main_layout);
    main_widget->setMinimumSize(520,500);
    this->setCentralWidget(main_widget);

    //connection
    connect(addTask, SIGNAL(clicked()),
            this->my_task_list,SLOT(addTask()));

    connect(delTask, SIGNAL(clicked()),
            this->my_task_list,SLOT(delTask()));

    connect(editTask, SIGNAL(clicked()),
            this->my_task_list, SLOT(editTask()));

    connect(display_note, SIGNAL(triggered()),
            this->my_task_list, SLOT(show_hide_Note()));//the action one in the menu

    connect(change_font, SIGNAL(triggered()),
            this->my_task_list, SLOT(changeFont()));

    connect(pop_up, SIGNAL(clicked()),
            this->my_task_list, SLOT(pop_up()));

    connect(move_down, SIGNAL(clicked()),
            this->my_task_list, SLOT(move_down()));

    connect(new_grocery, SIGNAL(triggered()),
            this->my_task_list, SLOT(grocery()));

    connect(new_week_task, SIGNAL(triggered()),
            this->my_task_list, SLOT(week_task()));

    connect(new_service, SIGNAL(triggered()),
            this, SLOT(newServiceClick()));

    connect(sync_service, SIGNAL(triggered()),
            this, SLOT(syncClick()));
    connect(sync_service_off, SIGNAL(triggered()),
            this, SLOT(syncClickOff()));
    connect(send_service, SIGNAL(triggered()),
            this->my_sync_widget, SLOT(sendFiles()));
    connect(get_service, SIGNAL(triggered()),
            this->my_sync_widget, SLOT(getFiles()));
    connect(send_service_gtask, SIGNAL(triggered()),
            this->my_sync_widget, SLOT(sendFilesGTask()));
    connect(get_service_gtask, SIGNAL(triggered()),
            this->my_sync_widget, SLOT(getFilesGTask()));

    connect(search_button, SIGNAL(clicked()), this, SLOT(search_start()));

}
Exemplo n.º 7
0
Bool TERMWINDOWMEMBER dc15network(Bool master)
	{
	char line[100], line2[100];
	label here, there;
	FILE *file;
	int i, rms;
	Bool done = FALSE;

	netFailed = FALSE;

	const protocols *theProt = GetProtocolByKey(node->GetProtocol(), TRUE);

	if (!theProt)
		{
		doccr();
		cPrintf(getnetmsg(177));
		doCR();
		return (FALSE);
		}

	if (!CommPort->HaveConnection())
		{
		return (FALSE);
		}

	sprintf(line, sbs, LocalTempPath, mesgTmp);
	unlink(line);

	sprintf(line, getnetmsg(123), LocalTempPath);
	unlink(line);

	sprintf(line, getnetmsg(124), LocalTempPath);
	unlink(line);

	sprintf(line, getnetmsg(125), LocalTempPath);
	unlink(line);

	if ((file = fopen(line, FO_AB)) == NULL)
		{
		perror(getnetmsg(25));
		return (FALSE);
		}

	for (i = get_first_room(here, there), rms = 0; i; i = get_next_room(here, there), rms++)
		{
		PutStr(file, there);
		}

	PutStr(file, ns);
	fclose(file);

	if (master)
		{
		sendRequest(theProt);
		if (!CommPort->HaveConnection())
			{
			return (FALSE);
			}

		reciveRequest(theProt);
		}
	else
		{
		reciveRequest(theProt);
		if (!CommPort->HaveConnection())
			{
			return (FALSE);
			}

		sendRequest(theProt);
		}

	if (!CommPort->HaveConnection() || netFailed)
		{
		return (FALSE);
		}

	if (master)
		{
		// clear the buffer
		while (CommPort->HaveConnection() && CommPort->IsInputReady())
			{
			CommPort->Input();
			}
		}

	makeSendFile();

	if (!CommPort->HaveConnection() || netFailed)
		{
		return (FALSE);
		}

	// wait for them to get their shit together
	cPrintf(getnetmsg(11));

	CommPort->Output('X');

	time_t t2 = 0;
	const time_t t = time(NULL);

	while (CommPort->HaveConnection() && !done)
		{
		if (time(NULL) > (t + (node->GetFetchTimeout() * 60)))
			{
			CITWINDOW *w = ScreenSaver.IsOn() ? NULL : CitWindowsMsg(NULL, getmsg(685), getmsg(73));

			Hangup();
			netFailed = TRUE;

			if (w)
				{
				destroyCitWindow(w, FALSE);
				}
			}

		KBReady();

		if (CommPort->IsInputReady())
			{
			i = CommPort->Input();
			if (i == 'X' || node->GetNetworkType() != NET_DCIT16)
				{
				done = TRUE;
				}
			else
				{
				DebugOut(pctc, i);
				}

			}

		// wake them up! (every second)
		if (time(NULL) != t2)
			{
			CommPort->Output('X');
			t2 = time(NULL);
			}

		// instantaneous reaction time isn't critical here
		CitIsIdle();
		}

	// wake them up!
	for (i = 0; i < 10; i++)
		{
		CommPort->Output('X');
		}

	doccr();

	if (!CommPort->HaveConnection() || netFailed)
		{
		return (FALSE);
		}

	if (master)
		{
		receiveFiles(theProt);
		if (!CommPort->HaveConnection() || netFailed)
			{
			return (FALSE);
			}

		sendFiles(theProt);
		}
	else
		{
		sendFiles(theProt);
		if (!CommPort->HaveConnection() || netFailed)
			{
			return (FALSE);
			}

		receiveFiles(theProt);
		}

	if (netFailed)
		{
		return (FALSE);
		}

	cPrintf(getnetmsg(84));
	doccr();

	CITWINDOW *w = ScreenSaver.IsOn() ? NULL : CitWindowsMsg(NULL, getmsg(82));

	Hangup();

	if (w)
		{
		destroyCitWindow(w, FALSE);
		}

	OC.setio(); // hmmm

	cPrintf(getnetmsg(85), cfg.Lmsg_nym);
	doccr();

	sformat(line, node->GetExtractPacket(), getmsg(48), roomdataIn, 0);
	apsystem(line, TRUE);

	changedir(LocalTempPath);
	unlink(roomdataIn);

	for (i = 0; i < rms; i++)
		{
		sprintf(line, getnetmsg(126), i);
		sprintf(line2, getnetmsg(127), i);
		rename(line, line2);
		}

	sprintf(line, sbs, LocalTempPath, mesgTmp);
	sprintf(line2, getnetmsg(123), LocalTempPath);
	rename(line, line2);

	return (TRUE);
	}