Example #1
0
static void registration_state_changed(LinphoneCore *lc, LinphoneProxyConfig *cfg, LinphoneRegistrationState state, const char *msg)
{
    ms_message("[BB10] Registration state changed: %s", msg);

    LinphoneManager *manager = (LinphoneManager *)linphone_core_get_user_data(lc);
    manager->onRegistrationStatusChanged(cfg, state);
}
Example #2
0
Q_DECL_EXPORT int main(int argc, char **argv)
{
    qmlRegisterType<ChatModel>();
    qmlRegisterType<ContactModel>();
    qmlRegisterType<HistoryModel>();
    qmlRegisterType<ListEditorHelper>();
    qmlRegisterType<CallStatsModel>();
    qmlRegisterType<AccountSettingsModel>();
    qmlRegisterType<LinphoneCallModel>("org.linphone", 1, 0, "LinphoneCallModel");

    qRegisterMetaType<LinphoneCall*>("LinphoneCall*");
    qmlRegisterType<bb::device::DisplayInfo>("bb.displayInfo", 1, 0, "DisplayInfo");

    Application app(argc, argv);
    app.setMenuEnabled(false);

    LinphoneManager *manager = LinphoneManager::createInstance(&app);
    manager->createAndStartLinphoneCore();

    // Create the Application UI object, this is where the main.qml file
    // is loaded and the application scene is set.
    ApplicationUI appui;

    // Enter the application main event loop.
    return Application::exec();
}
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);
                }
            }
        }
    }
}
Example #4
0
static void composing_received(LinphoneCore *lc, LinphoneChatRoom *room)
{
    LinphoneManager *manager = (LinphoneManager *)linphone_core_get_user_data(lc);
    manager->onComposingReceived(room);

    Q_UNUSED(lc);
    Q_UNUSED(room);
}
Example #5
0
static void message_received(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMessage *message)
{
    LinphoneManager *manager = (LinphoneManager *)linphone_core_get_user_data(lc);
    manager->onMessageReceived(room, message);

    Q_UNUSED(lc);
    Q_UNUSED(room);
    Q_UNUSED(message);
}
Example #6
0
static void call_state_changed(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState state, const char *msg)
{
    ms_message("[BB10] Call state changed: %s", msg);

    LinphoneManager *manager = LinphoneManager::getInstance();
    manager->onCallStateChanged(call, state);

    Q_UNUSED(lc);
}
Example #7
0
static void call_encryption_changed(LinphoneCore *lc, LinphoneCall *call, bool_t on, const char *authentication_token)
{
    LinphoneManager *manager = (LinphoneManager *)linphone_core_get_user_data(lc);
    if (on) {
        manager->onCallEncryptionChanged(call);
    }

    Q_UNUSED(lc);
    Q_UNUSED(authentication_token);
}
Example #8
0
static void countUnreadChatMessages(void *item, void *user_data)
{
    LinphoneManager *manager = (LinphoneManager *)user_data;
    LinphoneChatRoom *room = (LinphoneChatRoom *)item;
    if (room == NULL || manager == NULL)
        return;

    int currentCount = manager->unreadChatMessages();
    currentCount += linphone_chat_room_get_unread_messages_count(room);
    manager->setUnreadChatMessages(currentCount);
}
Example #9
0
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;
}
Example #11
0
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;
}
void* ReadLinphoneOutputProc(void* arg)
{
	log_printf(LOG_ALL_OUT,LOG_LEVEL_INFO,"Enter read linphone output data thread.\n");
	LinphoneManager* selfPtr = (LinphoneManager*)arg;
	char readBuffer[MAX_READ_BUFFER+1] = {0};
	DWORD readCnt = 0;
	while(LINPHONE_STATUS_NOT_INIT != selfPtr->GetLinphoneStatus())
	{
		ReadFile(selfPtr->GetPipeReadHandle(),readBuffer,MAX_READ_BUFFER,&readCnt,NULL);
		if(0 != readCnt)
		{
			log_printf(LOG_ALL_OUT,LOG_LEVEL_INFO,readBuffer);
			if(strstr(readBuffer,"new incoming call"))
			{
				selfPtr->SetLinphoneStatus(LINPHONE_STATUS_ON_INCOMMING);
				selfPtr->AnswerLinphoneCall();
			}
			else if(strstr(readBuffer,"Call ended"))
			{
				selfPtr->SetLinphoneStatus(LINPHONE_STATUS_ON_IDLE);
			}
			memset(readBuffer,0,sizeof(readBuffer));
			continue;
		}
		Sleep(100);
	}
	return NULL;
}
Example #14
0
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);
}
Example #15
0
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();
}