void BPSEventListener::event(bps_event_t *event) { if (event != NULL) { if (bps_event_get_domain(event) == virtualkeyboard_get_domain()) { uint16_t code = bps_event_get_code(event); if (code == VIRTUALKEYBOARD_EVENT_VISIBLE) { int pixelsHeight = 0; virtualkeyboard_get_height(&pixelsHeight); if (pixelsHeight > _mPixelsHeightToConsiderKeyboardVisible) { _isKeyboardVisible = true; emit keyboardVisibilityUpdated(); } } else if (code == VIRTUALKEYBOARD_EVENT_HIDDEN && _isKeyboardVisible) { _isKeyboardVisible = false; emit keyboardVisibilityUpdated(); } else if (code == VIRTUALKEYBOARD_EVENT_INFO) { int pixelsHeight = 0; virtualkeyboard_get_height(&pixelsHeight); _isKeyboardVisible = pixelsHeight > _mPixelsHeightToConsiderKeyboardVisible; emit keyboardVisibilityUpdated(); } } else if (bps_event_get_domain(event) == netstatus_get_domain()) { if (NETSTATUS_INFO == bps_event_get_code(event)) { netstatus_info_t *info = netstatus_event_get_info(event); if (info) { bool networkReachable = netstatus_info_get_availability(info); ms_message("[BB10] Network status event: network reachable: %i", networkReachable); LinphoneManager *manager = LinphoneManager::getInstance(); linphone_core_set_network_reachable(manager->getLc(), networkReachable); } } } } }
static LinphoneCall* getCurrentCall() { LinphoneManager *manager = LinphoneManager::getInstance(); LinphoneCore *lc = manager->getLc(); if (linphone_core_get_calls_nb(lc) == 0) { return NULL; } LinphoneCall *call = linphone_core_get_current_call(lc); if (!call) { const MSList *calls = linphone_core_get_calls(lc); call = (LinphoneCall *) ms_list_nth_data(calls, 0); } return call; }
static QVariantMap fillEntryWithMessageValues(QVariantMap entry, LinphoneChatMessage *message) { entry["id"] = linphone_chat_message_get_storage_id(message); entry["message"] = QVariant::fromValue<LinphoneChatMessage*>(message); const char *text = linphone_chat_message_get_text(message); entry["text"] = QString::fromUtf8(text); time_t time = linphone_chat_message_get_time(message); entry["time"] = time; const LinphoneAddress* fromAddr = linphone_chat_message_get_from_address(message); QString from = GetDisplayNameFromLinphoneAddress(fromAddr); QString date = FormatDateForChat(time); bool_t isOutgoing = linphone_chat_message_is_outgoing(message); entry["isOutgoing"] = isOutgoing; if (isOutgoing) { LinphoneManager *manager = LinphoneManager::getInstance(); LinphoneCore *lc = manager->getLc(); LpConfig *lp = linphone_core_get_config(lc); entry["contactPhoto"] = lp_config_get_string(lp, "app", "avatar_url", "/images/avatar.png"); } else { ContactFound cf = ContactFetcher::getInstance()->findContact(linphone_address_get_username(fromAddr)); if (cf.id >= 0) { from = cf.displayName; entry["contactPhoto"] = cf.smallPicturePath; } else { entry["contactPhoto"] = "/images/avatar.png"; } } QString timeAndFrom = GetTime(time) + " - " + from; if (date.length() > 0) { timeAndFrom = date + " " + timeAndFrom; } entry["timeAndFrom"] = timeAndFrom; entry = updateFileTransferInformations(entry, message, -1, -1, -1, ProgressIndicatorState::Progress); entry = setMessageDeliveryState(entry, message); entry["selected"] = false; return entry; }
void CallModel::onOrientationAboutToChange(DisplayDirection::Type displayDirection, UIOrientation::Type uiOrientation) { LinphoneManager *manager = LinphoneManager::getInstance(); LinphoneCore *lc = manager->getLc(); if (uiOrientation == UIOrientation::Landscape) { _deviceOrientation = displayDirection; } else { _deviceOrientation = 0; } ms_debug("[BB10] device orientation about to change to %s", _deviceOrientation == 0 ? "portrait" : "landscape"); linphone_core_set_device_rotation(lc, _deviceOrientation); emit deviceOrientationChanged(); LinphoneCall *call = getCurrentCall(); if (call) { linphone_core_update_call(lc, call, NULL); } }
bool ChatModel::setSelectedConversationSipAddress(QString sipAddress) { _displayName = ""; if (_dataModel != NULL) { _dataModel->clear(); } _room = NULL; _isNewConversation = true; _linphoneAddress = ""; if (!sipAddress.isEmpty()) { _isNewConversation = false; LinphoneManager *manager = LinphoneManager::getInstance(); LinphoneCore *lc = manager->getLc(); LinphoneAddress *address = linphone_core_interpret_url(lc, sipAddress.toUtf8().constData()); if (!address) { return false; } _room = linphone_core_get_chat_room(lc, address); if (_room) { ContactFound contact = ContactFetcher::getInstance()->findContact(linphone_address_get_username(address)); if (contact.id >= 0) { _displayName = contact.displayName; } else { _displayName = GetDisplayNameFromLinphoneAddress(address); } _linphoneAddress = sipAddress; linphone_chat_room_mark_as_read(_room); emit messagesRead(sipAddress); LinphoneManager::getInstance()->markChatConversationReadInHub(linphone_address_as_string_uri_only(address)); updateMessagesList(); } emit remoteChateeChanged(); return true; } return false; }
CallModel::CallModel(QObject *parent) : QObject(parent), window_id(NULL), window_group(NULL), _pausedCallsDataModel(new GroupDataModel(this)), _conferenceCallsDataModel(new GroupDataModel(this)), _callStatsModel(new CallStatsModel(this)), _currentCall(NULL), _incomingCall(NULL), _outgoingCall(NULL), _isVideoEnabled(false), _videoUpdateInProgress(false), _isMicMuted(false), _isSpeakerEnabled(false), _areControlsVisible(true), _statsTimer(new QTimer(this)), _acceptCallUpdateTimer(new QTimer(this)), _dialerCallButtonMode(0), _deviceOrientation(0), _previewSize(QSize(0, 0)), _mediaInProgress(false), _acceptCallUpdatedByRemoteVisible(false), _callUpdatedByRemote(NULL), _isPausedByRemote(false) { _pausedCallsDataModel->setGrouping(ItemGrouping::None); _pausedCallsDataModel->setSortedAscending(false); _conferenceCallsDataModel->setGrouping(ItemGrouping::None); _conferenceCallsDataModel->setSortedAscending(false); bool result = QObject::connect(LinphoneManager::getInstance(), SIGNAL(callStateChanged(LinphoneCall*)), this, SLOT(callStateChanged(LinphoneCall*))); Q_ASSERT(result); result = QObject::connect(LinphoneManager::getInstance(), SIGNAL(callEncryptionChanged(LinphoneCall*)), this, SLOT(callEncryptionChanged(LinphoneCall*))); Q_ASSERT(result); result = QObject::connect(_statsTimer, SIGNAL(timeout()), this, SLOT(statsTimerTimeout())); Q_ASSERT(result); result = QObject::connect(_acceptCallUpdateTimer, SIGNAL(timeout()), this, SLOT(acceptCallUpdatedByRemoteTimeout())); Q_ASSERT(result); result = connect(OrientationSupport::instance(), SIGNAL(displayDirectionAboutToChange(bb::cascades::DisplayDirection::Type, bb::cascades::UIOrientation::Type)), this, SLOT(onOrientationAboutToChange(bb::cascades::DisplayDirection::Type, bb::cascades::UIOrientation::Type))); Q_ASSERT(result); // Set the current rotation of the device UIOrientation::Type currentOrientation = OrientationSupport::instance()->orientation(); DisplayDirection::Type displayDirection = OrientationSupport::instance()->displayDirection(); LinphoneManager *manager = LinphoneManager::getInstance(); LinphoneCore *lc = manager->getLc(); if (currentOrientation == UIOrientation::Landscape) { _deviceOrientation = displayDirection; emit deviceOrientationChanged(); } ms_debug("[BB10] default device orientation: %s", _deviceOrientation == 0 ? "portrait" : "landscape"); linphone_core_set_device_rotation(lc, _deviceOrientation); _statsTimer->setInterval(1000); _acceptCallUpdateTimer->setInterval(30000); Q_UNUSED(result); }
void CallModel::callStateChanged(LinphoneCall *call) { if (!call) { call = getCurrentCall(); } if (!call) { return; } LinphoneCallState state = linphone_call_get_state(call); const LinphoneCallParams *params = linphone_call_get_current_params(call); const LinphoneAddress *addr = linphone_call_get_remote_address(call); QString sipUri = linphone_address_as_string_uri_only(addr); LinphoneManager *manager = LinphoneManager::getInstance(); LinphoneCore *lc = manager->getLc(); if (state == LinphoneCallIncomingReceived || state == LinphoneCallOutgoingInit) { if (!_statsTimer->isActive()) { _statsTimer->start(); } ContactFound contact = ContactFetcher::getInstance()->findContact(linphone_address_get_username(addr)); QString displayName, photo, sipUri; if (contact.id >= 0) { displayName = contact.displayName; photo = contact.picturePath; } else { displayName = GetDisplayNameFromLinphoneAddress(addr); photo = "/images/avatar.png"; } LinphoneCallModel *model = new LinphoneCallModel(this, call, GetAddressFromLinphoneAddress(addr), displayName, photo); linphone_call_set_user_data(call, model); if (state == LinphoneCallIncomingReceived) { _incomingCall = model; emit incomingCallChanged(); } else { _outgoingCall = model; emit outgoingCallChanged(); } } else if (state == LinphoneCallEnd || state == LinphoneCallError) { LinphoneCallModel *model = (LinphoneCallModel *)linphone_call_get_user_data(call); delete(model); linphone_call_set_user_data(call, NULL); pausedCalls(); conferenceCalls(); if (linphone_core_get_calls_nb(lc) == 0) { if (_statsTimer->isActive()) { _statsTimer->stop(); } _isSpeakerEnabled = false; _isMicMuted = false; _isVideoEnabled = false; emit callControlsUpdated(); emit conferenceUpdated(); } } else if (state == LinphoneCallStreamsRunning) { _videoUpdateInProgress = false; _mediaInProgress = linphone_call_media_in_progress(call); emit mediaInProgressUpdated(); _currentCall = (LinphoneCallModel *)linphone_call_get_user_data(call); emit currentCallChanged(); _isPausedByRemote = false; emit callPausedByRemoteUpdated(); } else if (state == LinphoneCallResuming || state == LinphoneCallPaused) { pausedCalls(); } else if (state == LinphoneCallUpdatedByRemote) { bool localVideoEnabled = linphone_call_params_video_enabled(linphone_call_get_current_params(call)); bool remoteVideoEnabled = linphone_call_params_video_enabled(linphone_call_get_remote_params(call)); bool autoAcceptVideoPolicy = linphone_core_get_video_policy(lc)->automatically_accept; if (!localVideoEnabled && remoteVideoEnabled && !autoAcceptVideoPolicy) { linphone_core_defer_call_update(lc, call); _acceptCallUpdateTimer->start(); _acceptCallUpdatedByRemoteVisible = true; _callUpdatedByRemote = call; emit callUpdatedByRemote(); } } else if (state == LinphoneCallPausedByRemote) { _isPausedByRemote = true; emit callPausedByRemoteUpdated(); } setVideoEnabled(linphone_call_params_video_enabled(params)); setMicMuted(linphone_core_is_mic_muted(lc)); emit callStateChanged(); }