Button for creating credentials for gmail.

This commit is contained in:
Martin Rotter 2020-11-10 07:57:56 +01:00
parent 47d2eb05c4
commit fc3ebdf823
5 changed files with 25 additions and 8 deletions

View File

@ -7,6 +7,8 @@
#define GMAIL_OAUTH_TOKEN_URL "https://accounts.google.com/o/oauth2/token"
#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_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"

View File

@ -6,6 +6,7 @@
#include "miscellaneous/application.h"
#include "miscellaneous/iconfactory.h"
#include "network-web/oauth2service.h"
#include "network-web/webfactory.h"
#include "services/gmail/definitions.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_buttonBox, &QDialogButtonBox::accepted, this, &FormEditGmailAccount::onClickedOk);
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->setMinimum(GMAIL_MIN_BATCH_SIZE);
@ -172,6 +174,10 @@ void FormEditGmailAccount::execForEdit(GmailServiceRoot* existing_root) {
exec();
}
void FormEditGmailAccount::registerApi() {
qApp->web()->openUrlInExternalBrowser(GMAIL_REG_API_URL);
}
void FormEditGmailAccount::checkOAuthValue(const QString& value) {
auto* line_edit = qobject_cast<LineEditWithStatus*>(sender()->parent());

View File

@ -27,6 +27,7 @@ class FormEditGmailAccount : public QDialog {
void execForEdit(GmailServiceRoot* existing_root);
private slots:
void registerApi();
void testSetup();
void onClickedOk();
void onClickedCancel();

View File

@ -73,6 +73,13 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QPushButton" name="m_btnRegisterApi">
<property name="text">
<string>Get my credentials</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@ -153,20 +160,21 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>LabelWithStatus</class>
<extends>QWidget</extends>
<header>labelwithstatus.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>LineEditWithStatus</class>
<extends>QWidget</extends>
<header>lineeditwithstatus.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>LabelWithStatus</class>
<extends>QWidget</extends>
<header>labelwithstatus.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>m_btnRegisterApi</tabstop>
<tabstop>m_spinLimitMessages</tabstop>
<tabstop>m_btnTestSetup</tabstop>
</tabstops>

View File

@ -528,8 +528,8 @@ bool GmailNetworkFactory::obtainAndDecodeFullMessages(QList<Message>& messages,
if (msgs.contains(msg_id)) {
Message& msg = messages[msgs.value(msg_id)];
if (fillFullMessage(msg, msg_doc, feed_id)) {
// TODO: report error;
if (!fillFullMessage(msg, msg_doc, feed_id)) {
qWarningNN << "Failed to get full message for custom ID:" << QUOTE_W_SPACE_DOT(msg.m_customId);
}
}
}