Skip to content

Commit

Permalink
Merge branch 'master' into libpurple_multilevel_disco
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalyster authored Dec 8, 2020
2 parents a3b50aa + f3c9e7c commit e79f1dc
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 71 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: "CodeQL"

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
language: ['python', 'javascript']

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
10 changes: 8 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,14 @@ jobs:
rm /usr/local/include/Swiften/Network/DummyConnectionServer.h
rm /usr/local/include/Swiften/Network/DummyConnectionServerFactory.h
cmake -DCMAKE_BUILD_TYPE=Debug -DENABLE_TESTS=ON -DENABLE_FROTZ=OFF -DCMAKE_UNITY_BUILD=ON .
- name: Build tests
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: cpp
- name: Build
run: make -j4
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
- name: Run tests
run: make test

Expand All @@ -65,7 +71,7 @@ jobs:
7z x deps32.zip
shell: cmd
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.0.0
uses: microsoft/setup-msbuild@v1.0.2
- name: Configure build
run: |
set CMAKE_PREFIX_PATH=%cd%\deps32
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Publish

on:
on:
workflow_dispatch:
push:
branches:
- master
Expand Down
15 changes: 15 additions & 0 deletions backends/libpurple/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,10 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
adminLegacyName = "telegram";
adminAlias = "telegram";
}
else if (protocol == "prpl-eionrobb-instagram") {
adminLegacyName = "instagram";
adminAlias = "instagram";
}
if (!purple_find_prpl_wrapped(protocol.c_str())) {
LOG4CXX_INFO(logger, name.c_str() << ": Invalid protocol '" << protocol << "'");
np->handleDisconnected(user, 1, "Invalid protocol " + protocol);
Expand Down Expand Up @@ -1866,6 +1870,17 @@ void * requestInput(const char *title, const char *primary,const char *secondary
np->m_inputRequests[req->mainJID] = req;
return NULL;
}
else if (boost::starts_with(primaryString, "Enter the six-digit code")) {
LOG4CXX_INFO(logger, "prpl-eionrobb-instagram verification request");
np->handleMessage(np->m_accounts[account], np->adminLegacyName, std::string("Verification code: "));
inputRequest *req = new inputRequest;
req->ok_cb = (PurpleRequestInputCb)ok_cb;
req->user_data = user_data;
req->account = account;
req->mainJID = np->m_accounts[account];
np->m_inputRequests[req->mainJID] = req;
return NULL;
}
else {
LOG4CXX_WARN(logger, "Unhandled request input. primary=" << primaryString);
}
Expand Down
36 changes: 0 additions & 36 deletions spectrum/src/frontends/slack/SlackAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,42 +35,6 @@

namespace Transport {

DEFINE_LOGGER(slackAPILogger, "SlackAPI");

#define GET_ARRAY(FROM, NAME) Json::Value &NAME = FROM[#NAME]; \
if (!NAME.isArray()) { \
LOG4CXX_ERROR(slackAPILogger, "No '" << #NAME << "' object in the reply."); \
return; \
}

#define STORE_STRING(FROM, NAME) Json::Value &NAME##_tmp = FROM[#NAME]; \
if (!NAME##_tmp.isString()) { \
LOG4CXX_ERROR(slackAPILogger, "No '" << #NAME << "' string in the reply."); \
LOG4CXX_ERROR(slackAPILogger, data); \
return; \
} \
std::string NAME = NAME##_tmp.asString();

#define STORE_BOOL(FROM, NAME) Json::Value &NAME##_tmp = FROM[#NAME]; \
if (!NAME##_tmp.isBool()) { \
LOG4CXX_ERROR(slackAPILogger, "No '" << #NAME << "' string in the reply."); \
LOG4CXX_ERROR(slackAPILogger, data); \
return; \
} \
bool NAME = NAME##_tmp.asBool();

#define GET_OBJECT(FROM, NAME) Json::Value &NAME = FROM[#NAME]; \
if (!NAME.isObject()) { \
LOG4CXX_ERROR(slackAPILogger, "No '" << #NAME << "' object in the reply."); \
return; \
}

#define STORE_STRING_OPTIONAL(FROM, NAME) Json::Value &NAME##_tmp = FROM[#NAME]; \
std::string NAME; \
if (NAME##_tmp.isString()) { \
NAME = NAME##_tmp.asString(); \
}

SlackAPI::SlackAPI(Component *component, SlackIdManager *idManager, const std::string &token, const std::string &domain) : HTTPRequestQueue(component, domain) {
m_component = component;
m_token = token;
Expand Down
44 changes: 44 additions & 0 deletions spectrum/src/frontends/slack/SlackAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,50 @@
#include <algorithm>
#include <map>

DEFINE_LOGGER(slackAPILogger, "SlackAPI");

#define GET_ARRAY(FROM, NAME) Json::Value &NAME = FROM[#NAME]; \
if (!NAME.isArray()) { \
LOG4CXX_ERROR(slackAPILogger, "No '" << #NAME << "' object in the reply."); \
return; \
}

#define STORE_STRING(FROM, NAME) Json::Value &NAME##_tmp = FROM[#NAME]; \
if (!NAME##_tmp.isString()) { \
LOG4CXX_ERROR(slackAPILogger, "No '" << #NAME << "' string in the reply."); \
LOG4CXX_ERROR(slackAPILogger, data); \
return; \
} \
std::string NAME = NAME##_tmp.asString();

#define STORE_BOOL(FROM, NAME) Json::Value &NAME##_tmp = FROM[#NAME]; \
if (!NAME##_tmp.isBool()) { \
LOG4CXX_ERROR(slackAPILogger, "No '" << #NAME << "' string in the reply."); \
LOG4CXX_ERROR(slackAPILogger, data); \
return; \
} \
bool NAME = NAME##_tmp.asBool();

#define GET_OBJECT(FROM, NAME) Json::Value &NAME = FROM[#NAME]; \
if (!NAME.isObject()) { \
LOG4CXX_ERROR(slackAPILogger, "No '" << #NAME << "' object in the reply."); \
return; \
}

#define STORE_STRING_OPTIONAL(FROM, NAME) Json::Value &NAME##_tmp = FROM[#NAME]; \
std::string NAME; \
if (NAME##_tmp.isString()) { \
NAME = NAME##_tmp.asString(); \
}

#define STORE_INT(FROM, NAME) Json::Value &NAME##_tmp = FROM[#NAME]; \
if (!NAME##_tmp.isInt()) { \
LOG4CXX_ERROR(slackAPILogger, "No '" << #NAME << "' number in the reply."); \
LOG4CXX_ERROR(slackAPILogger, data); \
return; \
} \
int NAME = NAME##_tmp.asInt();

namespace Transport {

class Component;
Expand Down
36 changes: 4 additions & 32 deletions spectrum/src/frontends/slack/SlackRTM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,41 +72,13 @@ void SlackRTM::start() {
req->execute();
}

#define STORE_STRING(FROM, NAME) Json::Value &NAME##_tmp = FROM[#NAME]; \
if (!NAME##_tmp.isString()) { \
LOG4CXX_ERROR(slackRTMLogger, "No '" << #NAME << "' string in the reply."); \
LOG4CXX_ERROR(slackRTMLogger, payload); \
return; \
} \
std::string NAME = NAME##_tmp.asString();

#define STORE_STRING_OPTIONAL(FROM, NAME) Json::Value &NAME##_tmp = FROM[#NAME]; \
std::string NAME; \
if (NAME##_tmp.isString()) { \
NAME = NAME##_tmp.asString(); \
}

#define GET_OBJECT(FROM, NAME) Json::Value &NAME = FROM[#NAME]; \
if (!NAME.isObject()) { \
LOG4CXX_ERROR(slackRTMLogger, "No '" << #NAME << "' object in the reply."); \
return; \
}

#define STORE_INT(FROM, NAME) Json::Value &NAME##_tmp = FROM[#NAME]; \
if (!NAME##_tmp.isInt()) { \
LOG4CXX_ERROR(slackRTMLogger, "No '" << #NAME << "' number in the reply."); \
LOG4CXX_ERROR(slackRTMLogger, payload); \
return; \
} \
int NAME = NAME##_tmp.asInt();

void SlackRTM::handlePayloadReceived(const std::string &payload) {
void SlackRTM::handlePayloadReceived(const std::string &data) {
Json::Value d;
Json::CharReaderBuilder rbuilder;
std::shared_ptr<Json::CharReader> const reader(rbuilder.newCharReader());
if (!reader->parse(payload.c_str(), payload.c_str() + payload.size(), &d, NULL)) {
if (!reader->parse(data.c_str(), data.c_str() + data.size(), &d, NULL)) {
LOG4CXX_ERROR(slackRTMLogger, "Error while parsing JSON");
LOG4CXX_ERROR(slackRTMLogger, payload);
LOG4CXX_ERROR(slackRTMLogger, data);
return;
}

Expand Down Expand Up @@ -152,7 +124,7 @@ void SlackRTM::handlePayloadReceived(const std::string &payload) {
else if (type == "channel_joined"
|| type == "channel_created") {
std::map<std::string, SlackChannelInfo> &channels = m_idManager->getChannels();
SlackAPI::getSlackChannelInfo(NULL, true, d, payload, channels);
SlackAPI::getSlackChannelInfo(NULL, true, d, data, channels);
}
else if (type == "error") {
GET_OBJECT(d, error);
Expand Down

0 comments on commit e79f1dc

Please sign in to comment.