public boolean enConnect() {
try {
userStoreTrans = new THttpClient(userStoreUrl);
userStoreTrans.setCustomHeader("User-Agent", userAgent);
} catch (TTransportException e) {
QMessageBox mb = new QMessageBox(QMessageBox.Icon.Critical, "Transport Excepton", e.getLocalizedMessage());
mb.exec();
e.printStackTrace();
}
userStoreProt = new TBinaryProtocol(userStoreTrans);
userStore = new UserStore.Client(userStoreProt, userStoreProt);
syncSignal.saveUserStore.emit(userStore);
try {
//authResult = userStore.authenticate(username, password, consumerKey, consumerSecret);
user = userStore.getUser(authToken);
} catch (EDAMUserException e) {
QMessageBox mb = new QMessageBox(QMessageBox.Icon.Critical, "Error", "Invalid Authorization");
mb.exec();
isConnected = false;
return false;
} catch (EDAMSystemException e) {
QMessageBox mb = new QMessageBox(QMessageBox.Icon.Critical, "EDAM System Excepton", e.getLocalizedMessage());
mb.exec();
e.printStackTrace();
isConnected = false;
} catch (TException e) {
QMessageBox mb = new QMessageBox(QMessageBox.Icon.Critical, "Transport Excepton", e.getLocalizedMessage());
mb.exec();
e.printStackTrace();
isConnected = false;
}
boolean versionOk = false;
try {
versionOk = userStore.checkVersion("NixNote",
com.evernote.edam.userstore.Constants.EDAM_VERSION_MAJOR,
com.evernote.edam.userstore.Constants.EDAM_VERSION_MINOR);
} catch (TException e) {
e.printStackTrace();
isConnected = false;
}
if (!versionOk) {
System.err.println("Incomatible EDAM client protocol version");
isConnected = false;
}
//if (authResult != null) {
//user = authResult.getUser();
//authToken = authResult.getAuthenticationToken();
if (user == null || noteStoreUrlBase == null) {
logger.log(logger.LOW, "Error retrieving user information. Aborting.");
System.err.println("Error retrieving user information.");
isConnected = false;
QMessageBox mb = new QMessageBox(QMessageBox.Icon.Critical, tr("Connection Error"), tr("Error retrieving user information. Synchronization not complete"));
mb.exec();
return false;
}
noteStoreUrl = noteStoreUrlBase + user.getShardId();
syncSignal.saveAuthToken.emit(authToken);
syncSignal.saveNoteStore.emit(localNoteStore);
try {
noteStoreTrans = new THttpClient(noteStoreUrl);
noteStoreTrans.setCustomHeader("User-Agent", userAgent);
} catch (TTransportException e) {
QMessageBox mb = new QMessageBox(QMessageBox.Icon.Critical, "Transport Excepton", e.getLocalizedMessage());
mb.exec();
e.printStackTrace();
isConnected = false;
}
noteStoreProt = new TBinaryProtocol(noteStoreTrans);
localNoteStore =