Java Code Examples for org.jxmpp.stringprep.XmppStringprepException#printStackTrace()

The following examples show how to use org.jxmpp.stringprep.XmppStringprepException#printStackTrace() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChatService.java    From xyTalk-pc with GNU Affero General Public License v3.0 6 votes vote down vote up
public static void sendMessage(String roomId, String content) {
	EntityBareJid jid = null;
	try {
		jid = JidCreate.entityBareFrom(roomId);
	} catch (XmppStringprepException e1) {
		// TODO Auto-generated catch block
		e1.printStackTrace();
	}
	Chat chat = ChatManager.getInstanceFor(Launcher.connection).chatWith(jid);

	org.jivesoftware.smack.packet.Message message = new org.jivesoftware.smack.packet.Message();
	message.setType(Type.chat);
	message.addExtension(new Receipt());
	message.setBody(content);
	try {
		chat.send(message);
		DebugUtil.debug("chat.sendMessage::" + message.toString());
	} catch (NotConnectedException | InterruptedException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}

}
 
Example 2
Source File: ChatService.java    From xyTalk-pc with GNU Affero General Public License v3.0 6 votes vote down vote up
public static void sendMessage(String roomId, String content,ExtensionElement ext) {
	EntityBareJid jid = null;
	try {
		jid = JidCreate.entityBareFrom(roomId);
	} catch (XmppStringprepException e1) {
		// TODO Auto-generated catch block
		e1.printStackTrace();
	}
	Chat chat = ChatManager.getInstanceFor(Launcher.connection).chatWith(jid);

	org.jivesoftware.smack.packet.Message message = new org.jivesoftware.smack.packet.Message();
	message.setType(Type.chat);
	message.addExtension(ext);
	message.setBody(content);
	try {
		chat.send(message);
		DebugUtil.debug("chat.sendMessage::" + message.toString());
	} catch (NotConnectedException | InterruptedException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}

}
 
Example 3
Source File: MucManager.java    From Yahala-Messenger with MIT License 6 votes vote down vote up
public List<String> getRoomParticipants(String threadId) {
    List<EntityFullJid> usersJids = null;
    List<String> usersIds = new ArrayList<>();
    try {
        //RoomInfo roomInfo = manager.getRoomInfo(JidCreate.entityBareFrom(threadId));
        MultiUserChat multiUserChat = manager.getMultiUserChat(JidCreate.entityBareFrom(threadId));
        usersJids = multiUserChat.getOccupants();

        for (EntityFullJid entityFullJid : usersJids) {
            usersIds.add(entityFullJid.toString());
        }
    } catch (XmppStringprepException e) {
        e.printStackTrace();
    }

    return usersIds;
}
 
Example 4
Source File: StateService.java    From xyTalk-pc with GNU Affero General Public License v3.0 5 votes vote down vote up
public static void sendPing(String barejid){
	try {
			sendPing(JidCreate.from(barejid + "/Android"));
			sendPing(JidCreate.from(barejid + "/ios"));
			sendPing(JidCreate.from(barejid + "/pc"));
			sendPing(JidCreate.from(barejid + "/Spark"));
		} catch (XmppStringprepException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
Example 5
Source File: XMPPSession.java    From mangosta-android with Apache License 2.0 5 votes vote down vote up
private boolean checkIfMyIsAffiliationNone(Message message) {
    if (hasAffiliationsChangeExtension(message)) {
        MUCLightElements.AffiliationsChangeExtension affiliationsChangeExtension = MUCLightElements.AffiliationsChangeExtension.from(message);

        try {
            Jid jid = JidCreate.from(Preferences.getInstance().getUserXMPPJid());
            MUCLightAffiliation affiliation = affiliationsChangeExtension.getAffiliations().get(jid.asEntityJidIfPossible());
            return affiliation == MUCLightAffiliation.none;
        } catch (XmppStringprepException e) {
            e.printStackTrace();
        }
    }
    return false;
}
 
Example 6
Source File: Jid.java    From Pix-Art-Messenger with GNU General Public License v3.0 5 votes vote down vote up
static Jid ofEscaped(CharSequence jid) {
    try {
        return new WrappedJid(JidCreate.from(jid));
    } catch (XmppStringprepException e) {
        e.printStackTrace();
        throw new IllegalArgumentException(e);
    }
}
 
Example 7
Source File: Jid.java    From Conversations with GNU General Public License v3.0 5 votes vote down vote up
static Jid ofEscaped(CharSequence jid) {
    try {
        return new WrappedJid(JidCreate.from(jid));
    } catch (XmppStringprepException e) {
        e.printStackTrace();
        throw new IllegalArgumentException(e);
    }
}
 
Example 8
Source File: Notifications.java    From XMPPSample_Studio with Apache License 2.0 4 votes vote down vote up
public static void showIncomingMessageNotification(Context context,
                                                       boolean groupChat, String jid, String message, String displayName) {
        if (context == null)
            return;
        SharedPreferences prefs = PreferenceManager
                .getDefaultSharedPreferences(context);
        boolean notification = prefs.getBoolean("notification", true);
        if (!notification) {
            return;
        }
        NotificationManager nm = (NotificationManager) context
                .getSystemService(Context.NOTIFICATION_SERVICE);
        NotificationCompat.Builder localBuilder = new NotificationCompat.Builder(
                context);
//		messagesFrom.add(StringUtils.parseName(jid));
        try {
            messagesFrom.add(StringUtils.maybeToString((JidCreate.bareFrom(jid).getLocalpartOrNull())));
        } catch (XmppStringprepException e) {
            e.printStackTrace();
        }
        messageNumber++;
        if (messagesFrom.size() > 1) {
            localBuilder.setContentTitle(messageNumber + " messages from "
                    + messagesFrom.size() + " users");
        } else {
            if (groupChat) {
//				String username = StringUtils.parseBareAddress(StringUtils
//						.parseResource(jid));

                // Edited by Saveen 12-July-2016
                String username = jid;

                Log.e("taggi", "groupChat username :" + username);
                localBuilder.setContentTitle(username + " in group");
            } else {
                localBuilder.setContentTitle(displayName);
            }
        }
        localBuilder.setContentText(message);
        localBuilder.setSmallIcon(R.drawable.ic_launcher);
        localBuilder.setLargeIcon(BitmapFactory.decodeResource(
                context.getResources(), R.drawable.ic_launcher));
        localBuilder.setNumber(messageNumber);
        int defaults = 0;
        boolean sound = prefs.getBoolean("notificationsound", true);
        boolean vibrate = prefs.getBoolean("notificationvibrate", true);
        if (sound) {
            defaults |= Notification.DEFAULT_SOUND;
        }
        if (vibrate) {
            defaults |= Notification.DEFAULT_VIBRATE;
        }
        defaults |= Notification.DEFAULT_LIGHTS;
        localBuilder.setDefaults(defaults);

        if (groupChat) {

        } else {
            Intent notificationIntent = new Intent(context,
                    ActivityChatScreen.class);

            if (messagesFrom.size() == 1) {
                notificationIntent.putExtra("id", jid);
                Log.e("tag", "notification jid :" + jid);
                notificationIntent.putExtra(
                        "username",
                        DatabaseHelper.getInstance(context).getDisplayName(
                                context, jid));
            }
            PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
                    notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);
            localBuilder.setContentIntent(contentIntent);
        }

        nm.notify(10201, localBuilder.build());
    }