예제 #1
0
void Core::start()
{
    tox = tox_new();

    tox_callback_friendrequest(tox, onFriendRequest, this);
    tox_callback_friendmessage(tox, onFriendMessage, this);
    tox_callback_namechange(tox, onFriendNameChange, this);
    tox_callback_statusmessage(tox, onStatusMessageChanged, this);
    tox_callback_userstatus(tox, onUserStatusChanged, this);
    tox_callback_connectionstatus(tox, onConnectionStatusChanged, this);
    tox_callback_action(tox, onAction, this);

    uint8_t friendAddress[TOX_FRIEND_ADDRESS_SIZE];
    tox_getaddress(tox, friendAddress);

    emit friendAddressGenerated(CFriendAddress::toString(friendAddress));

    CString cUsername(Settings::getInstance().getUsername());
    tox_setname(tox, cUsername.data(), cUsername.size());

    bootstrapDht();

    timer->setInterval(30);
    timer->start();
}
예제 #2
0
파일: main.c 프로젝트: FullName/toxic
static Tox *init_tox()
{
    /* Init core */
    Tox *m = tox_new(TOX_ENABLE_IPV6_DEFAULT);
    if (m == NULL)
        return NULL;

    /* Callbacks */
    tox_callback_connectionstatus(m, on_connectionchange, NULL);
    tox_callback_friendrequest(m, on_request, NULL);
    tox_callback_friendmessage(m, on_message, NULL);
    tox_callback_namechange(m, on_nickchange, NULL);
    tox_callback_userstatus(m, on_statuschange, NULL);
    tox_callback_statusmessage(m, on_statusmessagechange, NULL);
    tox_callback_action(m, on_action, NULL);
#ifdef __linux__
    tox_setname(m, (uint8_t *) "Cool guy", sizeof("Cool guy"));
#elif defined(_WIN32)
    tox_setname(m, (uint8_t *) "I should install GNU/Linux", sizeof("I should install GNU/Linux"));
#elif defined(__APPLE__)
    tox_setname(m, (uint8_t *) "Hipster", sizeof("Hipster")); //This used to users of other Unixes are hipsters
#else
    tox_setname(m, (uint8_t *) "Registered Minix user #4", sizeof("Registered Minix user #4"));
#endif
    return m;
}