3 * This file is part of NixNote
4 * Copyright 2012 Randy Baumgarte
6 * This file may be licensed under the terms of of the
7 * GNU General Public License Version 2 (the ``GPL'').
9 * Software distributed under the License is distributed
10 * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
11 * express or implied. See the GPL for the specific language
12 * governing rights and limitations.
14 * You should have received a copy of the GPL along with this
15 * program. If not, go to http://www.gnu.org/licenses/gpl.html
16 * or write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 /* This class is used to listen to inbound network requests. It
22 * examines all of them to look for the OAuth reply. This reply
23 * is what we need to get access to Evernote.
26 package cx.fbn.nevernote.oauth;
28 import com.trolltech.qt.core.QIODevice;
29 import com.trolltech.qt.core.QObject;
30 import com.trolltech.qt.network.QNetworkAccessManager;
31 import com.trolltech.qt.network.QNetworkReply;
32 import com.trolltech.qt.network.QNetworkRequest;
34 import cx.fbn.nevernote.utilities.ApplicationLogger;
36 public class NNOAuthNetworkAccessManager extends QNetworkAccessManager {
37 public Signal1<String> tokenFound;
38 private ApplicationLogger logger;
40 public NNOAuthNetworkAccessManager(ApplicationLogger l){
42 tokenFound = new Signal1<String>();
46 public NNOAuthNetworkAccessManager(QObject qObject){
48 tokenFound = new Signal1<String>();
52 protected QNetworkReply createRequest(Operation op,
53 QNetworkRequest request, QIODevice outgoingData) {
55 logger.log(logger.EXTREME,"NNOAuthNetworkAccessManager URL request scheme: "
56 +request.url().scheme() + " " + request.url().toString());
57 String searchReq = "nnoauth?oauth_token=";
58 int pos = request.url().toString().indexOf(searchReq);
60 String token = request.url().toString().substring(pos+searchReq.length());
61 tokenFound.emit(token);
63 return super.createRequest(op, request, outgoingData);