/** * 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(); } }
/** * 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); }
/** * Constructor * * @param parent IMS service * @param invite Initial INVITE request */ public TerminatingOne2OneChatSession(ImsService parent, SipRequest invite) { super(parent, PhoneUtils.extractNumberFromUri(SipUtils.getAssertedIdentity(invite))); // Set first message InstantMessage firstMsg = ChatUtils.getFirstMessage(invite); setFirstMesssage(firstMsg); // Create dialog path createTerminatingDialogPath(invite); // Set contribution ID String id = ChatUtils.getContributionId(invite); setContributionID(id); if (RcsSettings.getInstance().isCPMSupported()) { if (logger.isActivated()) { logger.info("TerminatingFOne2OneSession1 CPMS"); } setConversationID(ChatUtils.getCoversationId(invite)); setInReplyID(ChatUtils.getInReplyId(invite)); } if (logger.isActivated()) { logger.info("TerminatingOne2OneChatSession From: " + ChatUtils.getFromAias(invite)); logger.info("TerminatingOne2OneChatSession Display name: " + this.getRemoteDisplayName()); } setRemoteDisplayName(this.getRemoteDisplayName()); }
/** * Receive a new video sharing invitation * * @param session Video sharing session */ public void receiveVideoSharingInvitation(VideoStreamingSession session) { if (logger.isActivated()) { logger.info("Receive video sharing invitation from " + session.getRemoteContact()); } // Extract number from contact String number = PhoneUtils.extractNumberFromUri(session.getRemoteContact()); VideoContent content = (VideoContent) session.getContent(); // Update rich call history RichCall.getInstance() .addCall( number, session.getSessionID(), RichCallData.EVENT_INCOMING, content, RichCallData.STATUS_STARTED); // Add session in the list VideoSharingSession sessionApi = new VideoSharingSession(session); addVideoSharingSession(sessionApi); // Broadcast intent related to the received invitation Intent intent = new Intent(RichCallApiIntents.VIDEO_SHARING_INVITATION); intent.putExtra("contact", number); intent.putExtra("contactDisplayname", session.getRemoteDisplayName()); intent.putExtra("sessionId", session.getSessionID()); intent.putExtra("videotype", content.getEncoding()); intent.putExtra("videowidth", content.getWidth()); intent.putExtra("videoheight", content.getHeight()); AndroidFactory.getApplicationContext().sendBroadcast(intent); }
/** * Receive an instant message (SIP MESSAGE) * * @param intent Resolved intent * @param message Instant message request */ public void receiveSipInstantMessage(Intent intent, SipRequest message) { // Broadcast intent related to the received invitation String contact = SipUtils.getAssertedIdentity(message); String number = PhoneUtils.extractNumberFromUri(contact); String displayName = SipUtils.getDisplayNameFromUri(message.getFrom()); intent.putExtra(MultimediaMessageIntent.EXTRA_CONTACT, number); intent.putExtra(MultimediaMessageIntent.EXTRA_DISPLAY_NAME, displayName); intent.putExtra(MultimediaMessageIntent.EXTRA_CONTENT, message.getRawContent()); // Broadcast intent related to the received invitation AndroidFactory.getApplicationContext().sendBroadcast(intent); }
/** * A new presence sharing invitation has been received * * @param contact Contact */ public void handlePresenceSharingInvitation(String contact) { if (logger.isActivated()) { logger.debug("Handle event presence sharing invitation"); } // Extract number from contact String number = PhoneUtils.extractNumberFromUri(contact); // Broadcast intent related to the received invitation Intent intent = new Intent(PresenceApiIntents.PRESENCE_INVITATION); intent.putExtra("contact", number); getApplicationContext().sendBroadcast(intent); }
/** * Receive a new SIP session invitation * * @param intent Resolved intent * @param session SIP session */ public void receiveSipSessionInvitation(Intent intent, GenericSipSession session) { // Add session in the list MultimediaSessionImpl sessionApi = new MultimediaSessionImpl(session); MultimediaSessionServiceImpl.addSipSession(sessionApi); // Broadcast intent related to the received invitation String number = PhoneUtils.extractNumberFromUri(session.getRemoteContact()); intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES); intent.putExtra(MultimediaSessionIntent.EXTRA_CONTACT, number); intent.putExtra(MultimediaSessionIntent.EXTRA_DISPLAY_NAME, session.getRemoteDisplayName()); intent.putExtra(MultimediaSessionIntent.EXTRA_SESSION_ID, session.getSessionID()); // Broadcast intent related to the received invitation AndroidFactory.getApplicationContext().sendBroadcast(intent); }
/** * Receive a new video sharing invitation * * @param session Video sharing session */ public void receiveVideoSharingInvitation(VideoStreamingSession session) { if (logger.isActivated()) { logger.info("Receive video sharing invitation from " + session.getRemoteContact()); } // Extract number from contact String number = PhoneUtils.extractNumberFromUri(session.getRemoteContact()); // Update rich call history VideoContent content = (VideoContent) session.getContent(); RichCallHistory.getInstance() .addVideoSharing( number, session.getSessionID(), VideoSharing.Direction.INCOMING, content, VideoSharing.State.INVITED); // Add session in the list VideoSharingImpl sessionApi = new VideoSharingImpl(session); VideoSharingServiceImpl.addVideoSharingSession(sessionApi); // Broadcast intent related to the received invitation Intent intent = new Intent(VideoSharingIntent.ACTION_NEW_INVITATION); intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES); intent.putExtra(VideoSharingIntent.EXTRA_CONTACT, number); intent.putExtra(VideoSharingIntent.EXTRA_DISPLAY_NAME, session.getRemoteDisplayName()); intent.putExtra(VideoSharingIntent.EXTRA_SHARING_ID, session.getSessionID()); intent.putExtra(VideoSharingIntent.EXTRA_ENCODING, content.getEncoding()); intent.putExtra(VideoSharingIntent.EXTRA_WIDTH, session.getVideoWidth()); intent.putExtra(VideoSharingIntent.EXTRA_HEIGHT, session.getVideoHeight()); AndroidFactory.getApplicationContext().sendBroadcast(intent); // Notify video sharing invitation listeners synchronized (lock) { final int N = listeners.beginBroadcast(); for (int i = 0; i < N; i++) { try { listeners.getBroadcastItem(i).onNewVideoSharing(session.getSessionID()); } catch (Exception e) { if (logger.isActivated()) { logger.error("Can't notify listener", e); } } } listeners.finishBroadcast(); } }
/** * Capabilities update notification has been received * * @param contact Contact * @param capabilities Capabilities */ public void handleCapabilitiesNotification(String contact, Capabilities capabilities) { if (logger.isActivated()) { logger.debug( "Handle capabilities update notification for " + contact + " (" + capabilities.toString() + ")"); } // Extract number from contact String number = PhoneUtils.extractNumberFromUri(contact); // Broadcast intent containing the new capabilities Intent intent = new Intent(CapabilityApiIntents.CONTACT_CAPABILITIES); intent.putExtra("contact", number); intent.putExtra("capabilities", capabilities); getApplicationContext().sendBroadcast(intent); // TODO keep only one intent here // Send GSMA UI Connector intent Intent intentGsma = new Intent(GsmaUiConnector.ACTION_CAPABILITIES_CHANGED); intentGsma.putExtra(GsmaUiConnector.EXTRA_CONTACT, number); intentGsma.putExtra(GsmaUiConnector.EXTRA_CAPABILITY_CHAT, capabilities.isImSessionSupported()); intentGsma.putExtra( GsmaUiConnector.EXTRA_CAPABILITY_FT, capabilities.isFileTransferSupported()); intentGsma.putExtra( GsmaUiConnector.EXTRA_CAPABILITY_IMAGE_SHARE, capabilities.isImageSharingSupported()); intentGsma.putExtra( GsmaUiConnector.EXTRA_CAPABILITY_VIDEO_SHARE, capabilities.isVideoSharingSupported()); intentGsma.putExtra( GsmaUiConnector.EXTRA_CAPABILITY_GEOLOCATION_PUSH, capabilities.isGeolocationPushSupported()); intentGsma.putExtra( GsmaUiConnector.EXTRA_CAPABILITY_CS_VIDEO, capabilities.isCsVideoSupported()); intentGsma.putExtra( GsmaUiConnector.EXTRA_CAPABILITY_PRESENCE_DISCOVERY, capabilities.isPresenceDiscoverySupported()); intentGsma.putExtra( GsmaUiConnector.EXTRA_CAPABILITY_SOCIAL_PRESENCE, capabilities.isSocialPresenceSupported()); intentGsma.putExtra( GsmaUiConnector.EXTRA_CAPABILITY_IPVOICECALL, capabilities.isIPVoiceCallSupported()); intentGsma.putExtra( GsmaUiConnector.EXTRA_CAPABILITY_IPVIDEOCALL, capabilities.isIPVideoCallSupported()); intentGsma.putStringArrayListExtra( GsmaUiConnector.EXTRA_CAPABILITY_EXTENSIONS, capabilities.getSupportedExtensions()); getApplicationContext().sendBroadcast(intentGsma); }
/** * A new presence info notification has been received for a given contact * * @param contact Contact * @param presense Presence info document */ public void presenceInfoNotificationForContact(String contact, PidfDocument presence) { if (logger.isActivated()) { logger.debug("Presence info notification for contact " + contact); } try { // Extract number from contact String number = PhoneUtils.extractNumberFromUri(contact); // Get the current presence info ContactInfo currentContactInfo = ContactsManager.getInstance().getContactInfo(contact); ContactInfo newContactInfo = currentContactInfo; if (currentContactInfo == null) { if (logger.isActivated()) { logger.warn("Contact " + contact + " not found in EAB: by-pass the notification"); } return; } PresenceInfo newPresenceInfo = currentContactInfo.getPresenceInfo(); if (newPresenceInfo == null) { newPresenceInfo = new PresenceInfo(); newContactInfo.setPresenceInfo(newPresenceInfo); } // Update the current capabilities Capabilities capabilities = new Capabilities(); Vector<Tuple> tuples = presence.getTuplesList(); for (int i = 0; i < tuples.size(); i++) { Tuple tuple = (Tuple) tuples.elementAt(i); boolean state = false; if (tuple.getStatus().getBasic().getValue().equals("open")) { state = true; } String id = tuple.getService().getId(); if (id.equalsIgnoreCase(PresenceUtils.FEATURE_RCS2_VIDEO_SHARE)) { capabilities.setVideoSharingSupport(state); } else if (id.equalsIgnoreCase(PresenceUtils.FEATURE_RCS2_IMAGE_SHARE)) { capabilities.setImageSharingSupport(state); } else if (id.equalsIgnoreCase(PresenceUtils.FEATURE_RCS2_FT)) { capabilities.setFileTransferSupport(state); } else if (id.equalsIgnoreCase(PresenceUtils.FEATURE_RCS2_CS_VIDEO)) { capabilities.setCsVideoSupport(state); } else if (id.equalsIgnoreCase(PresenceUtils.FEATURE_RCS2_CHAT)) { capabilities.setImSessionSupport(state); } } newContactInfo.setCapabilities(capabilities); // Update presence status String presenceStatus = PresenceInfo.UNKNOWN; Person person = presence.getPerson(); OverridingWillingness willingness = person.getOverridingWillingness(); if (willingness != null) { if ((willingness.getBasic() != null) && (willingness.getBasic().getValue() != null)) { presenceStatus = willingness.getBasic().getValue(); } } newPresenceInfo.setPresenceStatus(presenceStatus); // Update the presence info newPresenceInfo.setTimestamp(person.getTimestamp()); if (person.getNote() != null) { newPresenceInfo.setFreetext(person.getNote().getValue()); } if (person.getHomePage() != null) { newPresenceInfo.setFavoriteLink(new FavoriteLink(person.getHomePage())); } // Update geoloc info if (presence.getGeopriv() != null) { Geoloc geoloc = new Geoloc( presence.getGeopriv().getLatitude(), presence.getGeopriv().getLongitude(), presence.getGeopriv().getAltitude()); newPresenceInfo.setGeoloc(geoloc); } newContactInfo.setPresenceInfo(newPresenceInfo); // Update contacts database ContactsManager.getInstance().setContactInfo(newContactInfo, currentContactInfo); // Get photo Etag values String lastEtag = ContactsManager.getInstance().getContactPhotoEtag(contact); String newEtag = null; if (person.getStatusIcon() != null) { newEtag = person.getStatusIcon().getEtag(); } // Test if the photo has been removed if ((lastEtag != null) && (person.getStatusIcon() == null)) { if (logger.isActivated()) { logger.debug("Photo has been removed for " + contact); } // Update contacts database ContactsManager.getInstance().setContactPhotoIcon(contact, null); // Broadcast intent Intent intent = new Intent(PresenceApiIntents.CONTACT_PHOTO_CHANGED); intent.putExtra("contact", number); AndroidFactory.getApplicationContext().sendBroadcast(intent); } else // Test if the photo has been changed if ((person.getStatusIcon() != null) && (newEtag != null)) { if ((lastEtag == null) || (!lastEtag.equals(newEtag))) { if (logger.isActivated()) { logger.debug("Photo has changed for " + contact + ", download it in background"); } // Download the photo in background downloadPhotoForContact(contact, presence.getPerson().getStatusIcon().getUrl(), newEtag); } } // Broadcast intent Intent intent = new Intent(PresenceApiIntents.CONTACT_INFO_CHANGED); intent.putExtra("contact", number); getApplicationContext().sendBroadcast(intent); } catch (Exception e) { if (logger.isActivated()) { logger.error("Internal exception", e); } } }