void
FolderConfigWindow::_ApplyChanges()
{
	bool haveChanges = false;
	for (unsigned int i = 0; i < fFolderList.size(); i++) {
		FolderInfo& info = fFolderList[i];
		CheckBoxItem* item = (CheckBoxItem*)fFolderListView->ItemAt(i);
		if ((info.subscribed != item->Checked())) {
			haveChanges = true;
			break;
		}
	}
	if (!haveChanges)
		return;

	StatusWindow* status = new StatusWindow(B_TRANSLATE("Subcribe / Unsuscribe "
		"IMAP folders, have patience..."));
	status->Show();

	for (unsigned int i = 0; i < fFolderList.size(); i++) {
		FolderInfo& info = fFolderList[i];
		CheckBoxItem* item = (CheckBoxItem*)fFolderListView->ItemAt(i);
		if (info.subscribed && !item->Checked())
			fIMAPFolders.UnsubscribeFolder(info.folder);
		else if (!info.subscribed && item->Checked())
			fIMAPFolders.SubscribeFolder(info.folder);
	}

	status->PostMessage(B_QUIT_REQUESTED);
}
Example #2
0
// ============================================================================
// Plane status button handler
void GameUIMain::on_buttonStatus_clicked()
{
	StatusWindow* pStatus = new StatusWindow( scene() );
	pStatus->setWindowFlags(  Qt::WindowSystemMenuHint | pStatus->windowFlags() );
	pStatus->setMachine( scene()->plane() );
	
	scene()->addWindow( pStatus, 1.0 );
	pStatus->setFocus();
}
void
FolderConfigWindow::_LoadFolders()
{
	StatusWindow* status = new StatusWindow(
		B_TRANSLATE("Fetching IMAP folders, have patience..."));
	status->Show();

	BString server;
	fSettings.FindString("server", &server);
	int32 ssl;
	fSettings.FindInt32("flavor", &ssl);
	bool useSSL = false;
	if (ssl == 1)
		useSSL = true;

	BString username;
	fSettings.FindString("username", &username);

	BString password;
	char* passwd = get_passwd(&fSettings, "cpasswd");
	if (passwd != NULL) {
		password = passwd;
		delete[] passwd;
	}

	fIMAPFolders.Connect(server, username, password, useSSL);
	fFolderList.clear();
	fIMAPFolders.GetFolders(fFolderList);
	for (unsigned int i = 0; i < fFolderList.size(); i++) {
		FolderInfo& info = fFolderList[i];
		CheckBoxItem* item = new CheckBoxItem(info.folder, info.subscribed);
		fFolderListView->AddItem(item);
		item->SetListView(fFolderListView);
	}

	uint64 used, total;
	if (fIMAPFolders.GetQuota(used, total) == B_OK) {
		char buffer[256];
		BString quotaString = "Server storage: ";
		quotaString += string_for_size(used, buffer, 256);
		quotaString += " / ";
		quotaString += string_for_size(total, buffer, 256);
		quotaString += " used.";
		fQuotaView->SetText(quotaString);
	}

	status->PostMessage(B_QUIT_REQUESTED);
}
Example #4
0
void Container::newStatusWindow(const QString &server, const int port)
{
	// Create the new status window
	StatusWindow *statusWindow = new StatusWindow(mdiArea, parser);
	statusWindow->setWindowTitle(tr("Not Connected"));

	// Create the new IRCClient
	IRCClient *client = new IRCClient(this);
	statusWindow->setClient(client);

	// Add an entry in the window tree
	this->windowTree->addStatusWindow(client->cid, server, statusWindow);

	QHash<QString, MdiWindow *> windowHash;
	windowHash.insert(statusWindow->hashName(), statusWindow);

	this->windows.insert(client->cid, windowHash);

	if ((!server.isEmpty()) && (port > 0)) {
		// TODO: Connect to the server
		statusWindow->append(Config::Theme("INFO"),"--- Connecting to " + server + " (" + QString::number(port) + ")");
		client->connectToHost(server, port);
	}

	// Connect the IRCClient signals to the Container slots
	connect(client, SIGNAL(connected(IRCClient *)), this, SLOT(connected(IRCClient *)));
	connect(client, SIGNAL(disconnected(IRCClient *)), this, SLOT(disconnected(IRCClient *)));
	//connect(client, SIGNAL(ircError(IRCClient *, QAbstractSocket::SocketError)), this, SLOT(ircError(IRCClient *, QAbstractSocket::SocketError)));
	connect(client, SIGNAL(privateMessageReceived(IRCClient *, const QString &, const QString &, const QString &)), this, SLOT(privateMessageReceived(IRCClient *, const QString &, const QString &, const QString &)));
	connect(client, SIGNAL(channelMessageReceived(IRCClient *, const QString &, const QString &, const QString &, const QString &, const QString &)), this, SLOT(channelMessageReceived(IRCClient *, const QString &, const QString &, const QString &, const QString &, const QString &)));
	connect(client, SIGNAL(incomingData(IRCClient *, const QString &)), this, SLOT(incomingData(IRCClient *, const QString &)));
	connect(client, SIGNAL(channelJoined(IRCClient *, const QString &, const QString &)), this, SLOT(channelJoined(IRCClient *, const QString &, const QString &)));
	connect(client, SIGNAL(channelParted(IRCClient *, const QString &, const QString &)), this, SLOT(channelParted(IRCClient *, const QString &, const QString &)));
	connect(client, SIGNAL(channelJoinCompleteNickList(IRCClient *, const QString &, const QStringList &)), this, SLOT(channelJoinCompleteNickList(IRCClient *, const QString &, const QStringList &)));

	// connect the new status button to new status window
	connect(statusWindow, SIGNAL(newStatusWin()), this, SLOT(newStatusWindow()));
	connect(statusWindow, SIGNAL(closeEventTriggered(const int, const QString &)), this, SLOT(subWindowClosed(const int, const QString &)));

	statusWindow->show();
}
Example #5
0
void KDEPrintd::statusMessage(const QString &msg, int pid, const QString &appName)
{
    StatusWindow *w = m_windows.find(pid);
    if(!w && !msg.isEmpty())
    {
        w = new StatusWindow(pid);
        if(appName.isEmpty())
            w->setCaption(i18n("Printing Status - %1").arg("(pid=" + QString::number(pid) + ")"));
        else
            w->setCaption(i18n("Printing Status - %1").arg(appName));
        connect(w, SIGNAL(destroyed()), SLOT(slotClosed()));
        w->show();
        m_windows.insert(pid, w);
    }
    if(w)
    {
        if(!msg.isEmpty())
            w->setMessage(msg);
        else
            w->close();
    }
}
Example #6
0
status_t 
PrinterDriver::PrintJob
	(
	BFile 		*jobFile,		// spool file
	BNode 		*printerNode,	// printer node, used by OpenTransport() to find & load transport add-on
	BMessage 	*jobMsg			// job message
	)
{
	print_file_header	pfh;
	status_t			status;
	BMessage 			*msg;
	int32 				page;
	uint32				copy;
	uint32				copies;
	const int32         passes = 2;

	fJobFile		= jobFile;
	fPrinterNode	= printerNode;
	fJobMsg			= jobMsg;

	if (!fJobFile || !fPrinterNode) 
		return B_ERROR;

	if (fPrintTransport.Open(fPrinterNode) != B_OK) {
		return B_ERROR;
	}
	if (fPrintTransport.IsPrintToFileCanceled()) {
		return B_OK;
	}

	// read print file header	
	fJobFile->Seek(0, SEEK_SET);
	fJobFile->Read(&pfh, sizeof(pfh));
	
	// read job message
	fJobMsg = msg = new BMessage();
	msg->Unflatten(fJobFile);
	// We have to load the settings here for Dano/Zeta because they don't store 
	// all fields from the message returned by config_job in the job file!
	PrinterSettings::Read(printerNode, msg, PrinterSettings::kJobSettings);
	
	if (msg->HasInt32("copies")) {
		copies = msg->FindInt32("copies");
	} else {
		copies = 1;
	}
	
	// force creation of Report object
	Report::Instance();

	// show status window
	StatusWindow* statusWindow = new StatusWindow(passes, pfh.page_count, this);

	status = BeginJob();

	fPrinting = true;
	for (fPass = 0; fPass < passes && status == B_OK && fPrinting; fPass++) {
		for (copy = 0; copy < copies && status == B_OK && fPrinting; copy++) 
		{
			for (page = 1; page <= pfh.page_count && status == B_OK && fPrinting; page++) {
				statusWindow->NextPage();
				status = PrintPage(page, pfh.page_count);
			}
	
			// re-read job message for next page
			fJobFile->Seek(sizeof(pfh), SEEK_SET);
			msg->Unflatten(fJobFile);
		}
	}
	
	status_t s = EndJob();
	if (status == B_OK) status = s;

	delete fJobMsg;
	
	// close status window
	if (Report::Instance()->CountItems() != 0) {
		statusWindow->WaitForClose();
	}
	if (statusWindow->Lock()) {
		statusWindow->Quit();
	}

	// delete Report object
	Report::Instance()->Free();
	
	return status;
}
Example #7
0
DWORD WINAPI StatusWindow::ThreadProc(LPVOID lpParameter)
{
	HANDLE eventList[1];
	StatusWindow *me = (StatusWindow *)lpParameter;
	bool waitingForClose = false;

	eventList[0] = me->eventCommandSent;
	
	me->dialog = CreateDialogParam(hInstance, MAKEINTRESOURCE(IDD_STATUSWINDOW), NULL, StatusWindow::MainDialogProc, (LPARAM)me);
	
	MSG msg;
	while(1) {
		DWORD rv;
		rv = MsgWaitForMultipleObjects(1, eventList, FALSE, INFINITE, QS_ALLEVENTS);

		if((rv >= WAIT_OBJECT_0) && (rv < WAIT_OBJECT_0 + 1)) {
			if(rv == WAIT_OBJECT_0) {
				switch(me->command->type) {
					case StatusCommand::COMMAND_CLOSE:
						// csThreadAlive is going to be entered already by the other thread
						DestroyWindow(me->dialog);
						// Pump the remaining messages
						while(GetMessage(&msg, NULL, 0, 0) > 0);
						SetEvent(me->eventCommandAcknowledged);
						return(TRUE);


					case StatusCommand::COMMAND_LOGMESSAGE:
						int length;

						length = GetWindowTextLength(GetDlgItem(me->dialog, IDC_LOG));
						
						SendDlgItemMessage(me->dialog, IDC_LOG, EM_SETSEL, length, length);
						SendDlgItemMessage(me->dialog, IDC_LOG, EM_REPLACESEL, 0, (LPARAM)(TCHAR *)(static_cast<CommandLogMessage *>(me->command))->message);
						SendDlgItemMessage(me->dialog, IDC_LOG, WM_VSCROLL, SB_BOTTOM, (LPARAM)NULL);
						SetEvent(me->eventCommandAcknowledged);
						break;

					case StatusCommand::COMMAND_WAITFORCLOSE:
						waitingForClose = true;
						break;

					default:
						SetEvent(me->eventCommandAcknowledged);
						break;
				}
			}
		} else if(rv == WAIT_OBJECT_0 + 1) {
			while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) != 0) {
				if(msg.message == WM_QUIT) {
					if(waitingForClose) {
						me->threadAlive = false;
						SetEvent(me->eventCommandAcknowledged);
					} else {					
						// Flushes the messages and sets threadAlive to false
						me->CleanupThread();
					}
					return(TRUE);
				}
			
				if(!IsDialogMessage(me->dialog, &msg)) {
					TranslateMessage(&msg);
					DispatchMessage(&msg);
				}
			}
		}
	}
}