Created
November 26, 2012 13:50
-
-
Save soulfly/4148285 to your computer and use it in GitHub Desktop.
BlackBerry 5,6,7 Chat sample: Login to Chat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void LoginToChat(final String _jid, final String _password, final String _userid) | |
{ | |
UiApplication.getUiApplication().invokeLater(new Runnable() | |
{ | |
public void run() | |
{ | |
jidName = _jid; | |
String jid = ""; | |
String password = ""; | |
String server = SERVER; | |
String customPort = PORT; | |
Vector up = SavedData.getUserInfo(); | |
if (up != null) | |
{ | |
jid = (String)up.elementAt(2) + "-" + APP_ID + "-" + (String)up.elementAt(0) + "@" + SERVER; | |
jidFull = (String)up.elementAt(2) + "-" + APP_ID + "-" + (String)up.elementAt(0); | |
password = (String)up.elementAt(1); | |
} | |
else | |
{ | |
jid = _userid + "-" + APP_ID + "-" + _jid + "@" + SERVER; | |
jidFull = _userid + "-" + APP_ID + "-" + _jid; | |
password = _password; | |
} | |
if (jid.equals("") || server.equals("")) | |
{ | |
Dialog.alert(Contents.jid_sintax_error); | |
return; | |
} | |
else | |
{ | |
if (jid.indexOf('@') != -1) | |
{//subdomain exists | |
Datas.subdomain = jid.substring(jid.indexOf('@') + 1, jid.length()); | |
jid = jid.substring(0, jid.indexOf('@')); | |
Datas.hostname = Datas.subdomain; | |
} | |
else | |
{ | |
Datas.hostname = server; | |
Datas.subdomain = null; | |
} | |
Datas.jid = new Jid(jid + "@" + Datas.hostname); | |
if (Datas.jid.getResource() == null) Datas.jid.setResource("JabberMix"); | |
Datas.setPassword(password); | |
Datas.server_name = server; | |
Datas.jid.setMail(""); | |
Datas.isSSL = false; | |
Datas.isHTTP = false; | |
Datas.avatarFile = Contents.getImage("jmcAvatar"); | |
Datas.setJidAvatar(); | |
Datas.saveRecord(); | |
//empty roster, future retrieve offline | |
Datas.roster.clear(); | |
chat_manager.getGuiWaitConnect(); | |
chat_manager.internal_state = chat_manager.WAIT_CONNECT; | |
DebugStorage.getInstance().Log(0, "<OfflineScreen> LoginToChat: "); | |
DebugStorage.getInstance().Log(0, "<OfflineScreen> LOGIN: " + jid); | |
DebugStorage.getInstance().Log(0, "<OfflineScreen> PASSWORD: " + password); | |
if (Datas.isHTTP) | |
{ | |
chat_manager.cm.httpConnect(); //HTTP | |
} | |
else | |
{ | |
chat_manager.cm.connect(0); //TCP | |
} | |
} | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment