/** * Receive a new geoloc sharing invitation * * @param session Geoloc sharing session */ public void receiveGeolocSharingInvitation(GeolocTransferSession session) { if (logger.isActivated()) { logger.info("Receive geoloc sharing invitation from " + session.getRemoteContact()); } // Extract number from contact String number = PhoneUtils.extractNumberFromUri(session.getRemoteContact()); // Update rich call history RichCall.getInstance() .addCall( number, session.getSessionID(), RichCallData.EVENT_INCOMING, session.getContent(), RichCallData.STATUS_STARTED); // Add session in the list GeolocSharingSession sessionApi = new GeolocSharingSession(session); addGeolocSharingSession(sessionApi); // Broadcast intent related to the received invitation Intent intent = new Intent(RichCallApiIntents.GEOLOC_SHARING_INVITATION); intent.putExtra("contact", number); intent.putExtra("contactDisplayname", session.getRemoteDisplayName()); intent.putExtra("sessionId", session.getSessionID()); AndroidFactory.getApplicationContext().sendBroadcast(intent); }
/** * Receive a new geoloc sharing invitation * * @param session Geoloc sharing session */ public void receiveGeolocSharingInvitation(GeolocTransferSession session) { if (logger.isActivated()) { logger.info("Receive geoloc sharing invitation from " + session.getRemoteContact()); } // Extract number from contact String number = PhoneUtils.extractNumberFromUri(session.getRemoteContact()); // Add session in the list GeolocSharingImpl sessionApi = new GeolocSharingImpl(session); GeolocSharingServiceImpl.addGeolocSharingSession(sessionApi); // Broadcast intent related to the received invitation Intent intent = new Intent(GeolocSharingIntent.ACTION_NEW_INVITATION); intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES); intent.putExtra(GeolocSharingIntent.EXTRA_CONTACT, number); intent.putExtra(GeolocSharingIntent.EXTRA_DISPLAY_NAME, session.getRemoteDisplayName()); intent.putExtra(GeolocSharingIntent.EXTRA_SHARING_ID, session.getSessionID()); AndroidFactory.getApplicationContext().sendBroadcast(intent); // Notify geoloc sharing invitation listeners synchronized (lock) { final int N = listeners.beginBroadcast(); for (int i = 0; i < N; i++) { try { listeners.getBroadcastItem(i).onNewGeolocSharing(session.getSessionID()); } catch (Exception e) { if (logger.isActivated()) { logger.error("Can't notify listener", e); } } } listeners.finishBroadcast(); } }
/** * Initiate a geoloc sharing session * * @param contact Contact * @param geoloc Geoloc info * @return Geoloc sharing session * @throws ServerApiException */ public IGeolocSharingSession initiateGeolocSharing(String contact, GeolocPush geoloc) throws ServerApiException { if (logger.isActivated()) { logger.info("Initiate a geoloc sharing session with " + contact); } // Check permission ServerApiUtils.testPermission(); // Test IMS connection ServerApiUtils.testIms(); try { // Create a geoloc content String msgId = ChatUtils.generateMessageId(); String geolocDoc = ChatUtils.buildGeolocDocument(geoloc, ImsModule.IMS_USER_PROFILE.getPublicUri(), msgId); MmContent content = new GeolocContent("geoloc.xml", geolocDoc.getBytes().length, geolocDoc.getBytes()); // Initiate a sharing session GeolocTransferSession session = Core.getInstance() .getRichcallService() .initiateGeolocSharingSession(contact, content, geoloc); // Update rich call RichCall.getInstance() .addCall( contact, session.getSessionID(), RichCallData.EVENT_OUTGOING, session.getContent(), RichCallData.STATUS_STARTED); // Update rich messaging history GeolocMessage geolocMsg = new GeolocMessage(null, contact, geoloc, false); RichMessaging.getInstance().addOutgoingGeoloc(geolocMsg); // Add session in the list GeolocSharingSession sessionApi = new GeolocSharingSession(session); addGeolocSharingSession(sessionApi); return sessionApi; } catch (Exception e) { if (logger.isActivated()) { logger.error("Unexpected error", e); } throw new ServerApiException(e.getMessage()); } }