Button for creating credentials for gmail.
This commit is contained in:
parent
47d2eb05c4
commit
fc3ebdf823
5 changed files with 25 additions and 8 deletions
|
@ -7,6 +7,8 @@
|
||||||
#define GMAIL_OAUTH_TOKEN_URL "https://accounts.google.com/o/oauth2/token"
|
#define GMAIL_OAUTH_TOKEN_URL "https://accounts.google.com/o/oauth2/token"
|
||||||
#define GMAIL_OAUTH_SCOPE "https://mail.google.com/"
|
#define GMAIL_OAUTH_SCOPE "https://mail.google.com/"
|
||||||
|
|
||||||
|
#define GMAIL_REG_API_URL "https://console.developers.google.com/apis/credentials"
|
||||||
|
|
||||||
#define GMAIL_API_SEND_MESSAGE "https://www.googleapis.com/upload/gmail/v1/users/me/messages/send?uploadType=media"
|
#define GMAIL_API_SEND_MESSAGE "https://www.googleapis.com/upload/gmail/v1/users/me/messages/send?uploadType=media"
|
||||||
#define GMAIL_API_BATCH_UPD_LABELS "https://www.googleapis.com/gmail/v1/users/me/messages/batchModify"
|
#define GMAIL_API_BATCH_UPD_LABELS "https://www.googleapis.com/gmail/v1/users/me/messages/batchModify"
|
||||||
#define GMAIL_API_GET_ATTACHMENT "https://www.googleapis.com/gmail/v1/users/me/messages/%1/attachments/%2"
|
#define GMAIL_API_GET_ATTACHMENT "https://www.googleapis.com/gmail/v1/users/me/messages/%1/attachments/%2"
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "miscellaneous/application.h"
|
#include "miscellaneous/application.h"
|
||||||
#include "miscellaneous/iconfactory.h"
|
#include "miscellaneous/iconfactory.h"
|
||||||
#include "network-web/oauth2service.h"
|
#include "network-web/oauth2service.h"
|
||||||
|
#include "network-web/webfactory.h"
|
||||||
#include "services/gmail/definitions.h"
|
#include "services/gmail/definitions.h"
|
||||||
#include "services/gmail/gmailserviceroot.h"
|
#include "services/gmail/gmailserviceroot.h"
|
||||||
|
|
||||||
|
@ -39,6 +40,7 @@ FormEditGmailAccount::FormEditGmailAccount(QWidget* parent)
|
||||||
connect(m_ui.m_btnTestSetup, &QPushButton::clicked, this, &FormEditGmailAccount::testSetup);
|
connect(m_ui.m_btnTestSetup, &QPushButton::clicked, this, &FormEditGmailAccount::testSetup);
|
||||||
connect(m_ui.m_buttonBox, &QDialogButtonBox::accepted, this, &FormEditGmailAccount::onClickedOk);
|
connect(m_ui.m_buttonBox, &QDialogButtonBox::accepted, this, &FormEditGmailAccount::onClickedOk);
|
||||||
connect(m_ui.m_buttonBox, &QDialogButtonBox::rejected, this, &FormEditGmailAccount::onClickedCancel);
|
connect(m_ui.m_buttonBox, &QDialogButtonBox::rejected, this, &FormEditGmailAccount::onClickedCancel);
|
||||||
|
connect(m_ui.m_btnRegisterApi, &QPushButton::clicked, this, &FormEditGmailAccount::registerApi);
|
||||||
|
|
||||||
m_ui.m_spinLimitMessages->setValue(GMAIL_DEFAULT_BATCH_SIZE);
|
m_ui.m_spinLimitMessages->setValue(GMAIL_DEFAULT_BATCH_SIZE);
|
||||||
m_ui.m_spinLimitMessages->setMinimum(GMAIL_MIN_BATCH_SIZE);
|
m_ui.m_spinLimitMessages->setMinimum(GMAIL_MIN_BATCH_SIZE);
|
||||||
|
@ -172,6 +174,10 @@ void FormEditGmailAccount::execForEdit(GmailServiceRoot* existing_root) {
|
||||||
exec();
|
exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FormEditGmailAccount::registerApi() {
|
||||||
|
qApp->web()->openUrlInExternalBrowser(GMAIL_REG_API_URL);
|
||||||
|
}
|
||||||
|
|
||||||
void FormEditGmailAccount::checkOAuthValue(const QString& value) {
|
void FormEditGmailAccount::checkOAuthValue(const QString& value) {
|
||||||
auto* line_edit = qobject_cast<LineEditWithStatus*>(sender()->parent());
|
auto* line_edit = qobject_cast<LineEditWithStatus*>(sender()->parent());
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ class FormEditGmailAccount : public QDialog {
|
||||||
void execForEdit(GmailServiceRoot* existing_root);
|
void execForEdit(GmailServiceRoot* existing_root);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void registerApi();
|
||||||
void testSetup();
|
void testSetup();
|
||||||
void onClickedOk();
|
void onClickedOk();
|
||||||
void onClickedCancel();
|
void onClickedCancel();
|
||||||
|
|
|
@ -73,6 +73,13 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="4" column="0">
|
||||||
|
<widget class="QPushButton" name="m_btnRegisterApi">
|
||||||
|
<property name="text">
|
||||||
|
<string>Get my credentials</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -153,20 +160,21 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
|
||||||
<class>LabelWithStatus</class>
|
|
||||||
<extends>QWidget</extends>
|
|
||||||
<header>labelwithstatus.h</header>
|
|
||||||
<container>1</container>
|
|
||||||
</customwidget>
|
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>LineEditWithStatus</class>
|
<class>LineEditWithStatus</class>
|
||||||
<extends>QWidget</extends>
|
<extends>QWidget</extends>
|
||||||
<header>lineeditwithstatus.h</header>
|
<header>lineeditwithstatus.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>LabelWithStatus</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>labelwithstatus.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
|
<tabstop>m_btnRegisterApi</tabstop>
|
||||||
<tabstop>m_spinLimitMessages</tabstop>
|
<tabstop>m_spinLimitMessages</tabstop>
|
||||||
<tabstop>m_btnTestSetup</tabstop>
|
<tabstop>m_btnTestSetup</tabstop>
|
||||||
</tabstops>
|
</tabstops>
|
||||||
|
|
|
@ -528,8 +528,8 @@ bool GmailNetworkFactory::obtainAndDecodeFullMessages(QList<Message>& messages,
|
||||||
if (msgs.contains(msg_id)) {
|
if (msgs.contains(msg_id)) {
|
||||||
Message& msg = messages[msgs.value(msg_id)];
|
Message& msg = messages[msgs.value(msg_id)];
|
||||||
|
|
||||||
if (fillFullMessage(msg, msg_doc, feed_id)) {
|
if (!fillFullMessage(msg, msg_doc, feed_id)) {
|
||||||
// TODO: report error;
|
qWarningNN << "Failed to get full message for custom ID:" << QUOTE_W_SPACE_DOT(msg.m_customId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue