/** * Receive an image sharing invitation * * @param invite Initial invite */ public void receiveImageSharingInvitation(SipRequest invite) { if (logger.isActivated()) { logger.info("Receive an image sharing session invitation"); } // Test if call is established if (!getImsModule().getCallManager().isCallConnected()) { if (logger.isActivated()) { logger.debug("Rich call not established: reject the invitation"); } sendErrorResponse(invite, 606); return; } // Reject if there are already 2 bidirectional sessions with a given contact boolean rejectInvitation = false; String contact = SipUtils.getAssertedIdentity(invite); Vector<ContentSharingSession> currentSessions = getCShSessions(); if (currentSessions.size() >= 2) { // Already a bidirectional session if (logger.isActivated()) { logger.debug("Max sessions reached"); } rejectInvitation = true; } else if (currentSessions.size() == 1) { ContentSharingSession currentSession = currentSessions.elementAt(0); if (currentSession instanceof TerminatingImageTransferSession) { // Terminating session already used if (logger.isActivated()) { logger.debug("Max terminating sessions reached"); } rejectInvitation = true; } else if (!PhoneUtils.compareNumbers(contact, currentSession.getRemoteContact())) { // Not the same contact if (logger.isActivated()) { logger.debug("Only bidirectional session with same contact authorized"); } rejectInvitation = true; } } if (rejectInvitation) { if (logger.isActivated()) { logger.debug("The max number of sharing sessions is achieved: reject the invitation"); } sendErrorResponse(invite, 486); return; } // Create a new session ImageTransferSession session = new TerminatingImageTransferSession(this, invite); // Start the session session.startSession(); // Notify listener getImsModule().getCore().getListener().handleContentSharingTransferInvitation(session); }