MCPcopy Create free account
hub / github.com/bumptop/BumpTop / initialize

Method initialize

trunk/win/Source/TwitterClient.cpp:107–170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105}
106
107bool TwitterClient::initialize()
108{
109#if TWITTER_OAUTH
110 // XXX: do a quick test of the auth key/secret if they are set to see if they are valid
111
112 // prompt for login if we have no twitter oauth access token
113 const char * kTwitterCustomerKey = "JCHH0DSC1pbpQ6j0ROYtww";
114 const char * kTwitterCustomerSecret = "HlqAAa9IXc42oZ4fxYMISy0Xuwngya2LPaCIHaLn2A";
115 // set the saved access tokens
116 _oauthClient.setTokens(kTwitterCustomerKey, kTwitterCustomerSecret,
117 GLOBAL(settings).tw_oauth_key, GLOBAL(settings).tw_oauth_secret);
118
119 if (GLOBAL(settings).tw_oauth_key.isEmpty() ||
120 GLOBAL(settings).tw_oauth_secret.isEmpty())
121 {
122 bool gotReqToken = _oauthClient.getRequestToken("http://twitter.com/oauth/request_token",
123 kTwitterCustomerKey, kTwitterCustomerSecret);
124 if (gotReqToken)
125 {
126 _oauthClient.launchAuthorizationUrl("http://twitter.com/oauth/authorize");
127
128 // wait for them to return
129 dlgManager->clearState();
130 if (dlgManager->promptDialog(DialogTwitterAuth))
131 {
132 QString pin = dlgManager->getText().trimmed();
133 return _oauthClient.getAccessToken("http://twitter.com/oauth/access_token", pin);
134 }
135 }
136 return false;
137 }
138 return true;
139#else
140 // prompt for login if we have no twitter login/password
141 if (GLOBAL(settings).tw_login.isEmpty() ||
142 GLOBAL(settings).tw_password.isEmpty())
143 {
144 dlgManager->clearState();
145 if (dlgManager->promptDialog(DialogTwitterLogin))
146 {
147 GLOBAL(settings).tw_login = dlgManager->getText();
148 GLOBAL(settings).tw_password = dlgManager->getSubText();
149
150 // test this login and password!
151 if (account_verifyCredentials())
152 {
153 winOS->SaveSettingsFile();
154 }
155 else
156 {
157 GLOBAL(settings).tw_login.clear();
158 GLOBAL(settings).tw_password.clear();
159 printUniqueError("TwitterActorImpl", QT_TRANSLATE_NOOP("TwitpicClient", "Invalid login/password"));
160 return false;
161 }
162 }
163 else
164 {

Callers 1

onTransferCompleteMethod · 0.45

Calls 12

setTokensMethod · 0.80
getRequestTokenMethod · 0.80
clearStateMethod · 0.80
promptDialogMethod · 0.80
getAccessTokenMethod · 0.80
getSubTextMethod · 0.80
SaveSettingsFileMethod · 0.80
isEmptyMethod · 0.45
getTextMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected