use of org.awesomeapp.messenger.ImApp in project Zom-Android by zom.
the class SimpleAlertHandler method registerForBroadcastEvents.
public void registerForBroadcastEvents() {
ImApp app = (ImApp) mActivity.getApplication();
app.registerForBroadcastEvent(ImApp.EVENT_CONNECTION_DISCONNECTED, this);
}
use of org.awesomeapp.messenger.ImApp in project Zom-Android by zom.
the class SmpResponseActivity method respondSmp.
private void respondSmp(String sid, String answer) {
ImApp app = (ImApp) getApplication();
IOtrChatSession iOtrSession;
try {
IChatSession chatSession = app.getChatSession(mProviderId, -1, Address.stripResource(sid));
iOtrSession = chatSession.getDefaultOtrChatSession();
if (iOtrSession == null) {
OtrDebugLogger.log("no session in progress for provider " + mProviderId);
return;
}
iOtrSession.respondSmpVerification(answer);
} catch (RemoteException e) {
OtrDebugLogger.log("could not respond to SMP", e);
}
}
use of org.awesomeapp.messenger.ImApp in project Zom-Android by zom.
the class ContactListItem method deleteContact.
void deleteContact() {
try {
IImConnection mConn;
ImApp app = ((ImApp) ((Activity) getContext()).getApplication());
mConn = app.getConnection(mHolder.mProviderId, mHolder.mAccountId);
IContactListManager manager = mConn.getContactListManager();
int res = manager.removeContact(address);
if (res != ImErrorInfo.NO_ERROR) {
// mHandler.showAlert(R.string.error,
// ErrorResUtils.getErrorRes(getResources(), res, address));
}
} catch (RemoteException re) {
}
}
use of org.awesomeapp.messenger.ImApp in project Zom-Android by zom.
the class AccountAdapter method runBindTask.
private void runBindTask(final Activity context, final List<AccountInfo> accountInfoList) {
final Resources resources = context.getResources();
final ContentResolver resolver = context.getContentResolver();
final ImApp mApp = (ImApp) context.getApplication();
// if called multiple times
if (mBindTask != null)
mBindTask.cancel(false);
//
mBindTask = new AsyncTask<Void, Void, List<AccountSetting>>() {
@Override
protected List<AccountSetting> doInBackground(Void... params) {
List<AccountSetting> accountSettingList = new ArrayList<AccountSetting>();
for (AccountInfo ai : accountInfoList) {
accountSettingList.add(getAccountSettings(ai));
}
return accountSettingList;
}
private AccountSetting getAccountSettings(AccountInfo ai) {
AccountSetting as = new AccountSetting();
Cursor pCursor = resolver.query(Imps.ProviderSettings.CONTENT_URI, new String[] { Imps.ProviderSettings.NAME, Imps.ProviderSettings.VALUE }, Imps.ProviderSettings.PROVIDER + "=?", new String[] { Long.toString(ai.providerId) }, null);
if (pCursor != null) {
Imps.ProviderSettings.QueryMap settings = new Imps.ProviderSettings.QueryMap(pCursor, resolver, ai.providerId, false, null);
as.connectionStatus = ai.dbConnectionStatus;
as.activeUserName = ai.activeUserName;
as.domain = settings.getDomain();
as.host = settings.getServer();
as.port = settings.getPort();
/**
* IImConnection conn = mApp.getConnection(ai.providerId,settings.get);
* if (conn == null) {
* as.connectionStatus = ImConnection.DISCONNECTED;
* } else {
* try {
* as.connectionStatus = conn.getState();
* } catch (RemoteException e) {
* // TODO Auto-generated catch block
* e.printStackTrace();
* }
* }
*/
settings.close();
}
return as;
}
@Override
protected void onPostExecute(List<AccountSetting> result) {
// store
mBindTask = null;
// swap
AccountAdapter.super.swapCursor(mStashCursor);
if (mListener != null)
mListener.onPopulate();
}
};
mBindTask.execute();
}
use of org.awesomeapp.messenger.ImApp in project Zom-Android by zom.
the class AccountListItem method runBindTask.
private void runBindTask(final Resources r, final int providerId, final int accountId, final String nickname, final String activeUserName, final int dbConnectionStatus, final String presenceString) {
String mProviderNameText;
String mSecondRowText;
try {
Cursor pCursor = mResolver.query(Imps.ProviderSettings.CONTENT_URI, new String[] { Imps.ProviderSettings.NAME, Imps.ProviderSettings.VALUE }, Imps.ProviderSettings.PROVIDER + "=?", new String[] { Long.toString(providerId) }, null);
Imps.ProviderSettings.QueryMap settings = new Imps.ProviderSettings.QueryMap(pCursor, mResolver, providerId, false, /* keep updated */
mHandler);
String userDomain = settings.getDomain();
int connectionStatus = dbConnectionStatus;
IImConnection conn = ((ImApp) mActivity.getApplication()).getConnection(providerId, accountId);
if (conn == null) {
connectionStatus = ImConnection.DISCONNECTED;
} else {
try {
connectionStatus = conn.getState();
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if (mShowLongName)
// + '@' + userDomain;
mProviderNameText = activeUserName;
else
mProviderNameText = nickname;
switch(connectionStatus) {
case ImConnection.LOGGING_IN:
mSecondRowText = r.getString(R.string.signing_in_wait);
mIsSignedIn = true;
break;
case ImConnection.SUSPENDING:
case ImConnection.SUSPENDED:
mSecondRowText = r.getString(R.string.error_suspended_connection);
mIsSignedIn = true;
break;
case ImConnection.LOGGED_IN:
mIsSignedIn = true;
mSecondRowText = computeSecondRowText(presenceString, r, settings, true);
break;
case ImConnection.LOGGING_OUT:
mIsSignedIn = false;
mSecondRowText = r.getString(R.string.signing_out_wait);
break;
default:
mIsSignedIn = false;
mSecondRowText = computeSecondRowText(presenceString, r, settings, true);
break;
}
settings.close();
pCursor.close();
applyView(mProviderNameText, mIsSignedIn, mSecondRowText);
} catch (NullPointerException npe) {
Log.d(ImApp.LOG_TAG, "null on QueryMap (this shouldn't happen anymore, but just in case)", npe);
}
}
Aggregations