GroupCreationWizardPageInfo::GroupCreationWizardPageInfo(ClientConfiguration* clientConfiguration, QWidget *parent) : QWizardPage(parent), ui(new Ui::GroupCreationWizardPageInfo), clientConfiguration(clientConfiguration) {
    ui->setupUi(this);

	nameValidator = new QRegExpValidator(QRegExp(".+", Qt::CaseInsensitive, QRegExp::RegExp2), ui->edtName);
	ui->edtName->setValidator(nameValidator);

	ui->listWidget->clear();
	ui->listWidget->setSelectionMode(QListWidget::SelectionMode::MultiSelection);

	OPENMITTSU_CONNECT(ui->listWidget, itemSelectionChanged(), this, onListWidgetItemSelectionChanged());

	// Load all Identities
	ContactRegistry* contactRegistry = ContactRegistry::getInstance();
	QList<ContactId> knownIdentities = contactRegistry->getIdentities();
	QList<ContactId>::const_iterator it = knownIdentities.constBegin();
	QList<ContactId>::const_iterator end = knownIdentities.constEnd();

	ContactId const selfIdentity = (clientConfiguration == nullptr) ? ContactId(0) : clientConfiguration->getClientIdentity();
	for (; it != end; ++it) {
		if (*it == selfIdentity) {
			continue;
		}
		ContactListWidgetItem* clwi = new ContactListWidgetItem(contactRegistry->getIdentity(*it), contactRegistry->getNickname(*it));
		ui->listWidget->addItem(clwi);
	}
	ui->listWidget->clearSelection();
	isSelectionOkay = false;

	registerField("edtName*", ui->edtName);
	registerField("listWidget*", ui->listWidget);
}
Пример #2
0
ImageViewer::ImageViewer(QImage const& img) : ui(new Ui::ImageViewerWindow), image(img), scaleFactor(1.0) {
	ui->setupUi(this);

	this->setAttribute(Qt::WA_DeleteOnClose, true);

	// Setup connections from Menu Actions
	OPENMITTSU_CONNECT(ui->actionSave_as, triggered(), this, actionSaveAsOnClick());
	OPENMITTSU_CONNECT(ui->actionClose, triggered(), this, actionCloseOnClick());
	OPENMITTSU_CONNECT(ui->actionCopy_to_Clipboard, triggered(), this, actionCopyToClipboardOnClick());
	OPENMITTSU_CONNECT(ui->actionZoom_In, triggered(), this, actionZoomInOnClick());
	OPENMITTSU_CONNECT(ui->actionZoom_out, triggered(), this, actionZoomOutOnClick());
	OPENMITTSU_CONNECT(ui->actionReset_Zoom, triggered(), this, actionNormalSizeOnClick());
	OPENMITTSU_CONNECT(ui->actionFit_to_Window, triggered(), this, actionFitToWindowOnChange());

	ui->lblImage->setMode(PixmapLabel::Mode::TouchFromInside);
	ui->lblImage->setPixmap(QPixmap::fromImage(image));

    ui->lblImage->setBackgroundRole(QPalette::Base);
	ui->scrollArea->setBackgroundRole(QPalette::Dark);

    resize(QGuiApplication::primaryScreen()->availableSize() * 3.0 / 5.0);

	QString const message = tr("Image: %2x%3, Depth: %4").arg(image.width()).arg(image.height()).arg(image.depth());
	statusBar()->showMessage(message);

	ui->actionFit_to_Window->setChecked(true);
	actionFitToWindowOnChange();
}
Пример #3
0
void ContactRegistry::connectContact(Contact* contact) {
	OPENMITTSU_CONNECT(contact, dataChanged(), this, onContactDataChanged());
}
Пример #4
0
Client::Client(QWidget *parent) : QMainWindow(parent), protocolClient(nullptr), settings(nullptr), audioOutput(nullptr), connectionState(ConnectionState::STATE_DISCONNECTED), serverConfiguration(nullptr), clientConfiguration(nullptr), contactRegistry(ContactRegistry::getInstance()) {
	ui.setupUi(this);
	ui.listContacts->setContextMenuPolicy(Qt::CustomContextMenu);
	connectionTimer.start(500);
	OPENMITTSU_CONNECT(&connectionTimer, timeout(), this, connectionTimerOnTimer());

	QCoreApplication::setOrganizationName("BliZZarD");
	QCoreApplication::setOrganizationDomain("philippberger.de");
	QCoreApplication::setApplicationName("OpenMittsu");

	this->settings = new QSettings(this);
	// Initialize in the right thread
	MessageCenter* mc = MessageCenter::getInstance();
	mc->setTabContainer(ui.tabWidget);

	OPENMITTSU_CONNECT(mc, newUnreadMessageAvailable(ChatTab*), this, messageCenterOnHasUnreadMessages(ChatTab*));

	QString const apiServerRootCertificate = QStringLiteral("LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUVZVENDQTBtZ0F3SUJBZ0lKQU0xRFIvREJSRnBRTUEwR0NTcUdTSWIzRFFFQkJRVUFN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QWFPQjR6Q0IKNERBZEJnTlZIUTRFRmdRVXc2TGFDNytKNjJyS2RhVEEzN2tBWVlVYnJrZ3dnYkFHQTFVZEl3U0JxRENCcFlBVQp3NkxhQzcrSjYycktkYVRBMzdrQVlZVWJya2loZ1lHa2Z6QjlNUXN3Q1FZRFZRUUdFd0pEU0RFTE1Ba0dBMVVFCkNCTUNXa2d4RHpBTkJnTlZCQWNUQmxwMWNtbGphREVRTUE0R0ExVUVDaE1IVkdoeVpXVnRZVEVMTUFrR0ExVUUKQ3hNQ1EwRXhFekFSQmdOVkJBTVRDbFJvY21WbGJXRWdRMEV4SERBYUJna3Foa2lHOXcwQkNRRVdEV05oUUhSbwpjbVZsYldFdVkyaUNDUUROUTBmd3dVUmFVREFNQmdOVkhSTUVCVEFEQVFIL01BMEdDU3FHU0liM0RRRUJCUVVBCkE0SUJBUUFSSE15SUhCREZ1bCtodmpBQ3Q2cjBFQUhZd1I5R1FTZ2hJUXNmSHQ4Y3lWY3ptRW5KSDlocnZoOVEKVml2bTdtcmZ2ZWlobU5YQW40V2xHd1ErQUN1VnRUTHh3OEVyYlNUN0lNQU94OW5wSGYva25nblo0blN3VVJGOQpyQ0V5SHExNzlwTlhwT3paMjU3RTVyMGF2TU5OWFhEd3VsdzAzaUJFMjFlYmQwMHBHMTFHVnEvSTI2cys4QmpuCkRLUlBxdUtyU080L2x1RUR2TDRuZ2lRalpwMzJTOVoxSzlzVk96cXRRN0k5enplVUFEbTNhVmEvQnBhdzRpTVIKMVNJN285YUpZaVJpMWd4WVAyQlVBMUlGcXI4Tnp5ZkdEN3RSSGRxN2JaT3hYQWx1djgxZGNiejBTQlg4U2dWMQo0SEVLYzZ4TUFObllzL2FZS2p2bVAwVnBPdlJVCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0=");
	PublicKey const longTermServerPublicKey = PublicKey::fromHexString(QStringLiteral("b851ae1bf275ebe6851ca7f5206b495080927159787e9aaabbeb4e55af09d805"));

	serverConfiguration = new ServerConfiguration(QStringLiteral("g-xx.0.threema.ch"), 5222, longTermServerPublicKey, QStringLiteral("https://api.threema.ch/identity/%1"), QStringLiteral("Threema/2.2A"), apiServerRootCertificate, QStringLiteral("https://%1.blob.threema.ch/%2"), QStringLiteral("https://%1.blob.threema.ch/%2/done"), QStringLiteral("https://upload.blob.threema.ch/upload"), QStringLiteral("Threema/2.2A"), apiServerRootCertificate);

	// Load stored settings
	if (settings->contains("clientConfigurationFile")) {
		if (validateClientConfigurationFile(settings->value("clientConfigurationFile").toString(), true)) {
			this->clientConfiguration = new ClientConfiguration(ClientConfiguration::fromFile(settings->value("clientConfigurationFile").toString()));
			updateClientSettingsInfo(settings->value("clientConfigurationFile").toString());
		} else {
			LOGGER_DEBUG("Removing key \"clientConfigurationFile\" from stored settings as the file is not valid.");
			settings->remove("clientConfigurationFile");
		}
	}
	// Load Contacts
	if (settings->contains("contactsFile")) {
		if (validateKnownIdentitiesFile(settings->value("contactsFile").toString(), true)) {
			contactRegistry->fromFile(settings->value("contactsFile").toString());
			updateKnownContactsInfo(settings->value("contactsFile").toString());
		} else {
			LOGGER_DEBUG("Removing key \"contactsFile\" from stored settings as the file is not valid.");
			settings->remove("contactsFile");
		}
	}

	OPENMITTSU_CONNECT(contactRegistry, identitiesChanged(), this, contactRegistryOnIdentitiesChanged());
	OPENMITTSU_CONNECT(ui.btnConnect, clicked(), this, btnConnectOnClick());
	OPENMITTSU_CONNECT(ui.btnOpenClientIni, clicked(), this, btnOpenClientIniOnClick());
	OPENMITTSU_CONNECT(ui.btnOpenContacts, clicked(), this, btnOpenContactsOnClick());
	OPENMITTSU_CONNECT(ui.listContacts, itemDoubleClicked(QListWidgetItem*), this, listContactsOnDoubleClick(QListWidgetItem*));
	OPENMITTSU_CONNECT(ui.listContacts, customContextMenuRequested(const QPoint&), this, listContactsOnContextMenu(const QPoint&));
	OPENMITTSU_CONNECT(ui.tabWidget, currentChanged(int), this, chatTabWidgetOnCurrentTabChanged(int));

	// Menus
	OPENMITTSU_CONNECT(ui.actionLicense, triggered(), this, menuAboutLicenseOnClick());
	OPENMITTSU_CONNECT(ui.actionAbout, triggered(), this, menuAboutAboutOnClick());
	OPENMITTSU_CONNECT(ui.actionAbout_Qt, triggered(), this, menuAboutAboutQtOnClick());
	OPENMITTSU_CONNECT(ui.actionAdd_a_Contact, triggered(), this, menuContactAddOnClick());
	OPENMITTSU_CONNECT(ui.actionDelete_a_Contact, triggered(), this, menuContactDeleteOnClick());
	OPENMITTSU_CONNECT(ui.actionEdit_a_Contact, triggered(), this, menuContactEditOnClick());
	OPENMITTSU_CONNECT(ui.actionSave_to_file, triggered(), this, menuContactSaveToFileOnClick());
	OPENMITTSU_CONNECT(ui.actionAdd_Group, triggered(), this, menuGroupAddOnClick());
	OPENMITTSU_CONNECT(ui.actionEdit_Group, triggered(), this, menuGroupEditOnClick());
	OPENMITTSU_CONNECT(ui.actionLeave_Group, triggered(), this, menuGroupLeaveOnClick());
	OPENMITTSU_CONNECT(ui.actionCreate_Backup, triggered(), this, menuIdentityCreateBackupOnClick());
	OPENMITTSU_CONNECT(ui.actionLoad_Backup, triggered(), this, menuIdentityLoadBackupOnClick());
	OPENMITTSU_CONNECT(ui.actionShow_Fingerprint, triggered(), this, menuIdentityShowFingerprintOnClick());
	OPENMITTSU_CONNECT(ui.actionShow_Public_Key, triggered(), this, menuIdentityShowPublicKeyOnClick());
	OPENMITTSU_CONNECT(ui.actionStatistics, triggered(), this, menuAboutStatisticsOnClick());
	OPENMITTSU_CONNECT(ui.actionExit, triggered(), this, menuFileExitOnClick());

	protocolClientThread.start();
	protocolClient = nullptr;
	OPENMITTSU_CONNECT(&protocolClientThread, finished(), this, threadFinished());

	// Load audio resources
	QAudioFormat format;
	format.setSampleRate(44100);
	format.setChannelCount(2);
	format.setSampleSize(16);
	format.setCodec("audio/pcm");
	format.setByteOrder(QAudioFormat::LittleEndian);
	format.setSampleType(QAudioFormat::UnSignedInt);
	audioOutput = new QAudioOutput(format, this);

	OPENMITTSU_CONNECT(audioOutput, stateChanged(QAudio::State), this, audioOutputOnStateChanged(QAudio::State));

	receivedMessageAudioFile.setFileName(":/audio/ReceivedMessage.wav");
	if (!receivedMessageAudioFile.open(QFile::ReadOnly)) {
		throw InternalErrorException() << "Could not load audio file ReceivedMessage.wav in the Client.";
	}

	// Call Updater
	OPENMITTSU_CONNECT_QUEUED(&updater, foundNewVersion(int, int, int, int, QString, QString, QString), this, updaterFoundNewVersion(int, int, int, int, QString, QString, QString));
	QTimer::singleShot(0, &updater, SLOT(start()));


	// Call the setup() function in the thread
	QTimer::singleShot(0, protocolClient, SLOT(setup()));
	contactRegistryOnIdentitiesChanged();

	// Restore Window location and size
	restoreGeometry(settings->value("clientMainWindowGeometry").toByteArray());
	restoreState(settings->value("clientMainWindowState").toByteArray());
}