Exemple #1
0
void cmd_reject(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
{
    const char *error_str;

    if (argc != 0) {
        error_str = "Unknown arguments.";
        goto on_error;
    }

    if ( !ASettins.av ) {
        error_str = "Audio not supported!";
        goto on_error;
    }

    ToxAvError error = toxav_reject(ASettins.av, self->call_idx, "Why not?");

    if ( error != ErrorNone ) {
        if ( error == ErrorInvalidState ) error_str = "Cannot reject in invalid state!";
        else if ( error == ErrorNoCall ) error_str = "No incoming call!";
        else error_str = "Internal error!";

        goto on_error;
    }

    /* Callback will print status... */

    return;
on_error:
    print_err (self, error_str);
}
    TERMINATE_SCOPE()



    /*************************************************************************************************
     * Other flows
     */

    /*
     * Call and reject
     */
    {
        int step = 0;
        int running = 1;

        while (running) {
            tox_do(bootstrap_node);
            tox_do(Alice);
            tox_do(Bob);

            switch ( step ) {
                case 0: /* Alice */
                    printf("Alice is calling...\n");
                    toxav_call(status_control.Alice.av, 0, TypeAudio, 10);
                    step++;
                    break;
                    \

                case 1: /* Bob */
                    if (status_control.Bob.status == Ringing) {
                        printf("Bob rejects...\n");
                        toxav_reject(status_control.Bob.av, "Who likes D's anyway?");
                        step++;
                    }

                    break;

                case 2:  /* Wait for Both to have status ended */
                    if (status_control.Alice.status == Rejected && status_control.Bob.status == Ended) running = 0;

                    break;
            }

            c_sleep(20);
        }

        printf("\n");
    }
Exemple #3
0
void stop_current_call(ToxWindow* self)
{    
    ToxAvCallState callstate;
    if ( ASettins.av != NULL && self->call_idx != -1 && 
       ( callstate = toxav_get_call_state(ASettins.av, self->call_idx) ) != av_CallNonExistant) {
        switch (callstate)
        {
        case av_CallActive:
        case av_CallHold:
            toxav_hangup(ASettins.av, self->call_idx);
            break;
        case av_CallInviting:
            toxav_cancel(ASettins.av, self->call_idx, 0, "Not interested anymore");
            break;
        case av_CallStarting:
            toxav_reject(ASettins.av, self->call_idx, "Not interested");
            break;
        default:
            break;
        }
    }
}
Exemple #4
0
void do_phone ( av_session_t *_phone )
{
    INFO("Welcome to tox_phone version: " _USERAGENT "\n"
         "Usage: \n"
         "f [pubkey] (add friend)\n"
         "c [a/v] (type) [friend] (friend id) (calls friend if online)\n"
         "h (if call is active hang up)\n"
         "a [a/v] (answer incoming call: a - audio / v - audio + video (audio is default))\n"
         "r (reject incoming call)\n"
         "q (quit)\n"
         "================================================================================"
        );

    while ( 1 ) {
        char _line [ 1500 ];
        int _len;

        if ( -1 == getinput(_line, 1500, &_len) ) {
            printf(" >> ");
            fflush(stdout);
            continue;
        }

        if ( _len > 1 && _line[1] != ' ' && _line[1] != '\n' ) {
            INFO("Invalid input!");
            continue;
        }

        switch (_line[0]) {

            case 'f': {
                char _id [128];
                strncpy(_id, _line + 2, 128);

                av_add_friend(_phone, _id);

            }
            break;

            case 'c': {
                ToxAvCallType _ctype;

                if ( _len < 5 ) {
                    INFO("Invalid input; usage: c a/v [friend]");
                    break;
                } else if ( _line[2] == 'a' || _line[2] != 'v' ) { /* default and audio */
                    _ctype = TypeAudio;
                } else { /* video */
                    _ctype = TypeVideo;
                }

                char *_end;
                int _friend = strtol(_line + 4, &_end, 10);

                if ( *_end ) {
                    INFO("Friend num has to be numerical value");
                    break;
                }

                if ( toxav_call(_phone->av, _friend, _ctype, 30) == ErrorAlreadyInCall ) {
                    INFO("Already in a call");
                    break;
                } else INFO("Calling friend: %d!", _friend);

            }
            break;

            case 'h': {
                if ( toxav_hangup(_phone->av) == ErrorNoCall ) {
                    INFO("No call!");
                    break;
                } else INFO("Hung up...");

            }
            break;

            case 'a': {
                ToxAvError rc;

                if ( _len > 1 && _line[2] == 'v' ) {
                    rc = toxav_answer(_phone->av, TypeVideo);
                } else
                    rc = toxav_answer(_phone->av, TypeAudio);

                if ( rc == ErrorInvalidState ) {
                    INFO("No call to answer!");
                }

            }
            break;

            case 'r': {
                if ( toxav_reject(_phone->av, "User action") == ErrorInvalidState )
                    INFO("No state to cancel!");
                else INFO("Call Rejected...");

            }
            break;

            case 'q': {
                INFO("Quitting!");
                return;
            }

            case '\n': {
            }

            default: {
            } break;

        }

    }
}
Exemple #5
0
void Cyanide::av_invite_reject(int fid)
{
    Friend *f = &friends[fid];
    toxav_reject(toxav, f->call_index, ""); //TODO add reason
    emit signal_friend_callstate(fid, (f->callstate = 0));
}
Exemple #6
0
void Core::rejectCall(int32_t callId)
{
    qDebug() << QString("Core: rejecting call %1").arg(callId);
    calls[callId].active = false;
    toxav_reject(toxav, callId, nullptr);
}