Skip to content

Instantly share code, notes, and snippets.

View soulfly's full-sized avatar

Mr. software craftsman soulfly

View GitHub Profile
@soulfly
soulfly / BlackBerry 5,6,7 Chat sample: Login to Chat
Created November 26, 2012 13:50
BlackBerry 5,6,7 Chat sample: Login to Chat
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;
@soulfly
soulfly / gist:4148169
Created November 26, 2012 13:22
BlackBerry 5,6,7 Chat sample: Send message
// Method sends and gets messages
public void run() {
try {
if (chat_manager.currentConversation.isMulti) {
vman.add(new SeparatorField());
GroupChat chat =
(GroupChat)Datas.multichat.get(chat_manager.currentConversation.name);
vman.add(new LabelField("Room Members:"));
if (chat != null) {
for (int j = 0; j < chat.jids.size(); j++) {
@soulfly
soulfly / gist:4148156
Created November 26, 2012 13:19
BlackBerry 5,6,7 Chat sample: Change status of the chat
if (field == bOnline) {
if (chat_manager.internal_state != chat_manager.OFFLINE &&
chat_manager.internal_state != chat_manager.WAIT_CONNECT && Datas.jid != null) {
Presence.changePresence(Presence.getPresence("online"),
Datas.jid.status_message);
Datas.jid.setPresence(Presence.getPresence("online"),
Datas.jid.status_message);
chat_manager.getGuiOnlineMenu();
}
} else if (field == bAway) {
@soulfly
soulfly / gist:4148141
Created November 26, 2012 13:17
BlackBerry chat sample 5,6,7: Add the new contacts to the contact list
chat_manager.internal_state = chat_manager.ONLINE;
boolean changes = false; // test if there are changes
boolean onlyphone = false;
boolean isNew = true;
if (chat_manager.currentjid == null ||
!jid.getText().equals(chat_manager.currentjid.getFullJid()) ||
!group.getText().equals(chat_manager.currentjid.group) || (phone.getText() != null &&
!phone.getText().equals(chat_manager.currentjid.phone))) {
if (chat_manager.currentjid != null &&
jid.getText().equals(chat_manager.currentjid.getFullJid()) &&
@soulfly
soulfly / gist:4148120
Created November 26, 2012 13:12
BlackBerry 5,6,7 Chat sample: Create session, User Sign Up, User Sign In
// Make request
public void doRequest(int type)
{
switch(type)
{
// Create session request
case REQUEST_SESSION:
{
String time = new Long(new Date().getTime()).toString();
String timestamp = time.substring(0, time.length()-3);