~morphis/phablet-extras/ofono-sms-status-report

« back to all changes in this revision

Viewing changes to src/stkagent.c

  • Committer: Stéphane Graber
  • Date: 2013-01-28 16:25:32 UTC
  • mfrom: (1.3.4)
  • Revision ID: stgraber@ubuntu.com-20130128162532-z710h30cuacyw36v
Merge version 1.12

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
        DBusPendingCall *call;
60
60
        void *user_cb;
61
61
        void *user_data;
 
62
        int min_length;
 
63
        int max_length;
 
64
        ofono_bool_t hidden_entry;
62
65
        ofono_destroy_func user_destroy;
63
66
 
64
67
        const struct stk_menu *request_selection_menu;
539
542
 
540
543
        if (dbus_message_get_args(reply, NULL,
541
544
                                        DBUS_TYPE_STRING, &digit,
542
 
                                        DBUS_TYPE_INVALID) == FALSE ||
543
 
                        strlen(digit) != 1 ||
544
 
                        !valid_phone_number_format(digit)) {
 
545
                                        DBUS_TYPE_INVALID) == FALSE) {
545
546
                ofono_error("Can't parse the reply to GetDigit()");
546
547
                remove_agent = TRUE;
547
548
                goto error;
548
549
        }
549
550
 
 
551
        if (strlen(digit) != 1 || !strspn(digit, "0123456789*#+")) {
 
552
                ofono_error("Invalid character");
 
553
                remove_agent = TRUE;
 
554
                goto error;
 
555
        }
 
556
 
 
557
        if (agent->hidden_entry && digit[0] == '+') {
 
558
                ofono_error("The character + is not allowed in this mode");
 
559
                remove_agent = TRUE;
 
560
                goto error;
 
561
        }
 
562
 
550
563
        cb(result, digit, agent->user_data);
551
564
 
552
565
        CALLBACK_END();
578
591
        agent->user_cb = cb;
579
592
        agent->user_data = user_data;
580
593
        agent->user_destroy = destroy;
 
594
        agent->hidden_entry = FALSE;
 
595
 
 
596
        dbus_pending_call_set_notify(agent->call, get_digit_cb, agent, NULL);
 
597
 
 
598
        return 0;
 
599
}
 
600
 
 
601
int stk_agent_request_quick_digit(struct stk_agent *agent, const char *text,
 
602
                                        const struct stk_icon_id *icon,
 
603
                                        stk_agent_string_cb cb, void *user_data,
 
604
                                        ofono_destroy_func destroy, int timeout)
 
605
{
 
606
        DBusConnection *conn = ofono_dbus_get_connection();
 
607
 
 
608
        agent->msg = dbus_message_new_method_call(agent->bus, agent->path,
 
609
                                                        OFONO_SIM_APP_INTERFACE,
 
610
                                                        "RequestQuickDigit");
 
611
        if (agent->msg == NULL)
 
612
                return -ENOMEM;
 
613
 
 
614
        dbus_message_append_args(agent->msg,
 
615
                                        DBUS_TYPE_STRING, &text,
 
616
                                        DBUS_TYPE_BYTE, &icon->id,
 
617
                                        DBUS_TYPE_INVALID);
 
618
 
 
619
        if (dbus_connection_send_with_reply(conn, agent->msg, &agent->call,
 
620
                                                timeout) == FALSE ||
 
621
                        agent->call == NULL)
 
622
                return -EIO;
 
623
 
 
624
        agent->user_cb = cb;
 
625
        agent->user_data = user_data;
 
626
        agent->user_destroy = destroy;
 
627
        agent->hidden_entry = TRUE;
581
628
 
582
629
        dbus_pending_call_set_notify(agent->call, get_digit_cb, agent, NULL);
583
630
 
660
707
        enum stk_agent_result result;
661
708
        gboolean remove_agent;
662
709
        char *string;
 
710
        int len, span;
663
711
 
664
712
        if (check_error(agent, reply,
665
713
                        ALLOWED_ERROR_GO_BACK | ALLOWED_ERROR_TERMINATE,
681
729
                goto error;
682
730
        }
683
731
 
 
732
        len = strlen(string);
 
733
 
 
734
        if (len < agent->min_length || len > agent->max_length) {
 
735
                ofono_error("Length not acceptable");
 
736
                remove_agent = TRUE;
 
737
                goto error;
 
738
        }
 
739
 
 
740
        if (agent->hidden_entry)
 
741
                span = strspn(string, "0123456789*#");
 
742
        else
 
743
                span = strspn(string, "0123456789*#+");
 
744
 
 
745
        if (span != len) {
 
746
                ofono_error("Invalid character found");
 
747
                remove_agent = TRUE;
 
748
                goto error;
 
749
        }
 
750
 
684
751
        cb(result, string, agent->user_data);
685
752
 
686
753
        CALLBACK_END();
724
791
        agent->user_cb = cb;
725
792
        agent->user_data = user_data;
726
793
        agent->user_destroy = destroy;
 
794
        agent->min_length = min_val;
 
795
        agent->max_length = max_val;
 
796
        agent->hidden_entry = hidden_val;
727
797
 
728
798
        dbus_pending_call_set_notify(agent->call, get_digits_cb, agent, NULL);
729
799
 
738
808
        enum stk_agent_result result;
739
809
        gboolean remove_agent;
740
810
        char *string;
 
811
        int len;
741
812
 
742
813
        if (check_error(agent, reply,
743
814
                        ALLOWED_ERROR_GO_BACK | ALLOWED_ERROR_TERMINATE,
759
830
                goto error;
760
831
        }
761
832
 
 
833
        len = g_utf8_strlen(string, -1);
 
834
 
 
835
        if (len < agent->min_length || len > agent->max_length) {
 
836
                ofono_error("Length not acceptable");
 
837
                remove_agent = TRUE;
 
838
                goto error;
 
839
        }
 
840
 
762
841
        cb(result, string, agent->user_data);
763
842
 
764
843
        CALLBACK_END();
803
882
        agent->user_cb = cb;
804
883
        agent->user_data = user_data;
805
884
        agent->user_destroy = destroy;
 
885
        agent->min_length = min_val;
 
886
        agent->max_length = max_val;
 
887
        agent->hidden_entry = hidden_val;
806
888
 
807
889
        dbus_pending_call_set_notify(agent->call, get_input_cb, agent, NULL);
808
890