From 1a1ccdca277664d1fdcd7715c35705d737bf1b62 Mon Sep 17 00:00:00 2001 From: keita Date: Sat, 23 Apr 2022 20:57:59 +0900 Subject: [PATCH] format --- src/cocoatweet/api/interface/httpGet.cc | 3 +-- src/cocoatweet/api/interface/httpPost.cc | 3 +-- src/cocoatweet/api/model/bearerToken.cc | 3 +-- src/cocoatweet/api/oauth1/accessToken.cc | 2 -- src/cocoatweet/api/oauth1/authenticate.h | 1 - src/cocoatweet/api/oauth1/invalidateToken.h | 2 -- src/cocoatweet/api/oauth1/oauth.cc | 16 ++++++++-------- src/cocoatweet/api/oauth2/invalidateToken.cc | 12 ++++++------ src/cocoatweet/api/oauth2/invalidateToken.h | 7 +++---- src/cocoatweet/api/oauth2/oauth2.cc | 11 ++++++----- src/cocoatweet/util/util.cc | 10 ++++------ src/main.cc | 2 -- 12 files changed, 30 insertions(+), 42 deletions(-) diff --git a/src/cocoatweet/api/interface/httpGet.cc b/src/cocoatweet/api/interface/httpGet.cc index d0e3ed5..5b1edba 100644 --- a/src/cocoatweet/api/interface/httpGet.cc +++ b/src/cocoatweet/api/interface/httpGet.cc @@ -142,8 +142,7 @@ void HttpGet::process(std::weak_ptr().c_str()); } else if (error.get() == 348) { - throw CocoaTweet::Exception::InvalidateTokenException( - message.get().c_str()); + throw CocoaTweet::Exception::InvalidateTokenException(message.get().c_str()); } else { } } diff --git a/src/cocoatweet/api/interface/httpPost.cc b/src/cocoatweet/api/interface/httpPost.cc index 51c5a3b..4853e24 100644 --- a/src/cocoatweet/api/interface/httpPost.cc +++ b/src/cocoatweet/api/interface/httpPost.cc @@ -159,8 +159,7 @@ void HttpPost::process(std::weak_ptr().c_str()); } else if (error.get() == 348) { - throw CocoaTweet::Exception::InvalidateTokenException( - message.get().c_str()); + throw CocoaTweet::Exception::InvalidateTokenException(message.get().c_str()); } } diff --git a/src/cocoatweet/api/model/bearerToken.cc b/src/cocoatweet/api/model/bearerToken.cc index 01920f1..29364b9 100644 --- a/src/cocoatweet/api/model/bearerToken.cc +++ b/src/cocoatweet/api/model/bearerToken.cc @@ -3,8 +3,7 @@ namespace CocoaTweet::API::Model { BearerToken::BearerToken() : token_("") {} -BearerToken::BearerToken(const std::string _token) - : token_(_token) {} +BearerToken::BearerToken(const std::string _token) : token_(_token) {} const std::string& BearerToken::token() const { return token_; } diff --git a/src/cocoatweet/api/oauth1/accessToken.cc b/src/cocoatweet/api/oauth1/accessToken.cc index 49d96f7..147b3ff 100644 --- a/src/cocoatweet/api/oauth1/accessToken.cc +++ b/src/cocoatweet/api/oauth1/accessToken.cc @@ -19,14 +19,12 @@ void AccessToken::oauthToken(const CocoaTweet::API::Model::OAuthToken _token) { const CocoaTweet::API::Model::OAuthToken AccessToken::process( std::weak_ptr _oauth) { - auto key = oauth_.lock()->key(); key.authType(CocoaTweet::Authentication::Key::AUTH_TYPE::OAUTH10A); key.accessToken(oauthToken_.oauthToken()); key.accessTokenSecret(oauthToken_.oauthTokenSecret()); auto oauth = std::make_shared(key); - CocoaTweet::API::Model::OAuthToken oauthToken; HttpPost::process(oauth, [&oauthToken](const std::string& _rcv) { auto mp = CocoaTweet::Util::parse(_rcv, '&', '='); diff --git a/src/cocoatweet/api/oauth1/authenticate.h b/src/cocoatweet/api/oauth1/authenticate.h index 473d86b..b725a22 100644 --- a/src/cocoatweet/api/oauth1/authenticate.h +++ b/src/cocoatweet/api/oauth1/authenticate.h @@ -1,5 +1,4 @@ #ifndef COCOATWEET_API_OAUTH1_AUTHENTICATE_H_ #define COCOATWEET_API_OAUTH1_AUTHENTICATE_H_ - #endif \ No newline at end of file diff --git a/src/cocoatweet/api/oauth1/invalidateToken.h b/src/cocoatweet/api/oauth1/invalidateToken.h index be8a8f0..3c9ad7d 100644 --- a/src/cocoatweet/api/oauth1/invalidateToken.h +++ b/src/cocoatweet/api/oauth1/invalidateToken.h @@ -1,6 +1,4 @@ #ifndef COCOATWEET_API_OAUTH1_INVALIDATETOKEN_H_ #define COCOATWEET_API_OAUTH1_INVALIDATETOKEN_H_ - - #endif \ No newline at end of file diff --git a/src/cocoatweet/api/oauth1/oauth.cc b/src/cocoatweet/api/oauth1/oauth.cc index 293aa9c..bc863ba 100644 --- a/src/cocoatweet/api/oauth1/oauth.cc +++ b/src/cocoatweet/api/oauth1/oauth.cc @@ -8,9 +8,9 @@ OAuth::OAuth(std::shared_ptr _oau CocoaTweet::API::Model::OAuthToken OAuth::requestToken( const std::string& _oauthCallback) const { -// auto key = oauth_.lock()->key(); -// key.authType(CocoaTweet::Authentication::Key::AUTH_TYPE::OAUTH10A); -// auto oauth = std::make_shared(key); + // auto key = oauth_.lock()->key(); + // key.authType(CocoaTweet::Authentication::Key::AUTH_TYPE::OAUTH10A); + // auto oauth = std::make_shared(key); CocoaTweet::API::OAuth1::RequestToken requestToken; requestToken.oauthCallback(_oauthCallback); @@ -25,11 +25,11 @@ const std::string OAuth::authorize(const CocoaTweet::API::Model::OAuthToken _oau const CocoaTweet::API::Model::OAuthToken OAuth::accessToken( const CocoaTweet::API::Model::OAuthToken _oauthToken, const std::string _verifier) const { -// auto key = oauth_.lock()->key(); -// key.authType(CocoaTweet::Authentication::Key::AUTH_TYPE::OAUTH10A); -// key.accessToken(_oauthToken.oauthToken()); -// key.accessTokenSecret(_oauthToken.oauthTokenSecret()); -// auto oauth = std::make_shared(key); + // auto key = oauth_.lock()->key(); + // key.authType(CocoaTweet::Authentication::Key::AUTH_TYPE::OAUTH10A); + // key.accessToken(_oauthToken.oauthToken()); + // key.accessTokenSecret(_oauthToken.oauthTokenSecret()); + // auto oauth = std::make_shared(key); CocoaTweet::API::OAuth1::AccessToken accessToken; accessToken.oauthVerifier(_verifier); return accessToken.process(oauth_); diff --git a/src/cocoatweet/api/oauth2/invalidateToken.cc b/src/cocoatweet/api/oauth2/invalidateToken.cc index 4a38f01..3f424e0 100644 --- a/src/cocoatweet/api/oauth2/invalidateToken.cc +++ b/src/cocoatweet/api/oauth2/invalidateToken.cc @@ -7,16 +7,16 @@ InvalidateToken::InvalidateToken() { url_ = "https://api.twitter.com/oauth2/invalidate_token"; } -void InvalidateToken::accessToken(const std::string _bearer){ - // bodyParam_.insert_or_assign("access_token", _bearer); - bearer_ = _bearer; +void InvalidateToken::accessToken(const std::string _bearer) { + // bodyParam_.insert_or_assign("access_token", _bearer); + bearer_ = _bearer; } const CocoaTweet::API::Model::BearerToken InvalidateToken::process( std::weak_ptr _oauth) { - auto org = url_; - auto url = url_ + "?access_token=" + bearer_; - url_ = url; + auto org = url_; + auto url = url_ + "?access_token=" + bearer_; + url_ = url; auto basic = std::make_shared(_oauth.lock()->key()); CocoaTweet::API::Model::BearerToken bearer; HttpPost::process(basic, [&bearer](const std::string& _rcv) { diff --git a/src/cocoatweet/api/oauth2/invalidateToken.h b/src/cocoatweet/api/oauth2/invalidateToken.h index 649b9b5..a24fd4b 100644 --- a/src/cocoatweet/api/oauth2/invalidateToken.h +++ b/src/cocoatweet/api/oauth2/invalidateToken.h @@ -5,7 +5,7 @@ #include #include -namespace CocoaTweet::API::OAuth2{ +namespace CocoaTweet::API::OAuth2 { class InvalidateToken : public CocoaTweet::API::Interface::HttpPost { public: InvalidateToken(); @@ -14,9 +14,8 @@ public: std::weak_ptr _oauth); private: -std::string bearer_; + std::string bearer_; }; -} - +} // namespace CocoaTweet::API::OAuth2 #endif \ No newline at end of file diff --git a/src/cocoatweet/api/oauth2/oauth2.cc b/src/cocoatweet/api/oauth2/oauth2.cc index b99f914..0858725 100644 --- a/src/cocoatweet/api/oauth2/oauth2.cc +++ b/src/cocoatweet/api/oauth2/oauth2.cc @@ -7,16 +7,17 @@ OAuth2::OAuth2(std::shared_ptr _o } const std::string OAuth2::token() const { -// auto key = oauth_.lock()->key(); -// auto oauth = std::make_shared(key); + // auto key = oauth_.lock()->key(); + // auto oauth = std::make_shared(key); CocoaTweet::API::OAuth2::Token token; return token.process(oauth_); } - const CocoaTweet::API::Model::BearerToken OAuth2::invalidateToken(const std::string& _bearer) const { -// auto key = oauth_.lock()->key(); -// auto oauth = std::make_shared(key); +const CocoaTweet::API::Model::BearerToken OAuth2::invalidateToken( + const std::string& _bearer) const { + // auto key = oauth_.lock()->key(); + // auto oauth = std::make_shared(key); CocoaTweet::API::OAuth2::InvalidateToken invalidateToken; invalidateToken.accessToken(_bearer); diff --git a/src/cocoatweet/util/util.cc b/src/cocoatweet/util/util.cc index 74e0cb6..dd54b30 100644 --- a/src/cocoatweet/util/util.cc +++ b/src/cocoatweet/util/util.cc @@ -22,27 +22,25 @@ std::string urlEncode(const std::string& _str) { return out.str(); } -std::string urlDecode(const std::string& _str){ +std::string urlDecode(const std::string& _str) { std::stringstream out; int first = 0; int last = _str.find_first_of('%'); - - while (first < _str.size()) { if (last == std::string::npos) { out << _str.substr(first); break; } - auto s = _str.substr(first, last - first); - auto encoded = _str.substr(last+1, 2); // %を飛ばし読みする + auto s = _str.substr(first, last - first); + auto encoded = _str.substr(last + 1, 2); // %を飛ばし読みする std::cout << encoded << std::endl; auto c = static_cast(static_cast(strtol(encoded.c_str(), nullptr, 16))); out << s << c; - + first = last + 3; last = _str.find_first_of('%', first); } diff --git a/src/main.cc b/src/main.cc index 94f8513..cb8a3fb 100644 --- a/src/main.cc +++ b/src/main.cc @@ -49,8 +49,6 @@ auto main() -> int { user = api.user().show("milkcocoa9692"); std::cout << user.id() << std::endl; - - // api.directMessage().messageCreate( // user.id(), // "これはクソみたいなスパムDMです。\nCocoaTwitterLibraryで、user/"