Exemplo n.º 1
0
 protected InputHandlerResult handleShortcutLinks(
     UserSession us,
     string input)
 {
     if (input == RESET)
     {
         us.user_profile.user_profile_custom.setColourTheme(UserColourTheme.NO_THEME);
         us.setVariable(AScreenOutputAdapter.COLOUR_CHANGED, "COLOUR_CHANGED");
         return new InputHandlerResult(
          InputHandlerResult.DO_NOTHING_ACTION,
          InputHandlerResult.DEFAULT_MENU_ID,
          InputHandlerResult.DEFAULT_PAGE_ID);
     }
     int colour_theme = -1;
     if (!Int32.TryParse(input, out colour_theme))
     {
         return new InputHandlerResult(
            InputHandlerResult.INVALID_MENU_ACTION,
            "Invalid Input...");
     }
     //colour_theme -= 1;
     if (!UserColourTheme.isColourThemeValid(colour_theme))
     {
             return new InputHandlerResult(
                InputHandlerResult.INVALID_MENU_ACTION,
                "Invalid Input...");
     }
     us.user_profile.user_profile_custom.setColourTheme(colour_theme);
     us.setVariable(AScreenOutputAdapter.COLOUR_CHANGED, "COLOUR_CHANGED");
     return new InputHandlerResult(
                      InputHandlerResult.DO_NOTHING_ACTION,
                      InputHandlerResult.DEFAULT_MENU_ID,
                      InputHandlerResult.DEFAULT_PAGE_ID);
 }
Exemplo n.º 2
0
        public override InputHandlerResult handleInput(UserSession user_session, MessageReceived message_recieved)
        {
            string input = extractReply(message_recieved);
            //Console.WriteLine("in input handler: " + input);
            Console.WriteLine("User with ID: " + user_session.user_profile.id + " Entered: " + input);
            //get reply
            string curr_user_page = user_session.current_menu_loc;

            InputHandlerResult output = handleDisplayMessageLinks(
               user_session,
               input,
               "Your input was invalid. You message has been sent already but please click Back/Main to continue",
               true);

            if (output.action != (InputHandlerResult.UNDEFINED_MENU_ACTION))
            {
                if(output.action == InputHandlerResult.BACK_WITHOUT_INIT_MENU_ACTION)
                    user_session.setVariable(Browse_Bible_Handler.BROWSE_CLEAR_SCREEN, true);
                return output;
            }
            output = handleStdNavLinks(user_session, input,true);
            if (output.action != (InputHandlerResult.UNDEFINED_MENU_ACTION))
                return output;

            output = handleMyProfileLinks(user_session, input);
            if (output.action != (InputHandlerResult.UNDEFINED_MENU_ACTION))
                return output;

            //handle back or home here.

            return new InputHandlerResult(
                    "Invalid entry...Please enter a valid input"); //invalid choice
        }
Exemplo n.º 3
0
        /*this method either returns the new screen id or the main or prev command string*/
        protected InputHandlerResult handleFriendRequestLinks(
            UserSession user_session,
            string input)
        {
            string curr_user_page = user_session.current_menu_loc;
            String entry = input.ToUpper();
            long friend_id = -1;
            if (entry.StartsWith(APPROVE_REQUEST))
            {
                friend_id = long.Parse(entry.Split('_')[1]);
                user_session.friend_manager.approveFriendRequest(friend_id);
                String user_name = UserNameManager.getInstance().getUserName(friend_id);

                user_session.setVariable(APPROVED_FRIEND_NAME, user_name);

                return new InputHandlerResult(
                    InputHandlerResult.BACK_MENU_ACTION,
                    InputHandlerResult.DEFAULT_MENU_ID,
                    InputHandlerResult.DEFAULT_PAGE_ID); //the menu id is retreived from the session in this case.
            }
            else if (entry.StartsWith(REJECT_REQUEST))
            {
                friend_id = long.Parse(entry.Split('_')[1]);
                user_session.friend_manager.rejectFriendRequest(friend_id);
                String user_name = UserNameManager.getInstance().getUserName(friend_id);

                user_session.setVariable(REJECTED_FRIEND_NAME, user_name);
                return new InputHandlerResult(
                    InputHandlerResult.BACK_MENU_ACTION,
                    InputHandlerResult.DEFAULT_MENU_ID,
                    InputHandlerResult.DEFAULT_PAGE_ID); //the menu id is retreived from the session in this case.
            }
            else
            {
                return new InputHandlerResult(
                    InputHandlerResult.UNDEFINED_MENU_ACTION,
                    InputHandlerResult.DEFAULT_MENU_ID,
                    InputHandlerResult.DEFAULT_PAGE_ID);
            }
        }
Exemplo n.º 4
0
        public override InputHandlerResult handleInput(UserSession user_session, MessageReceived message_recieved)
        {
            string input = extractReply(message_recieved);
               // Console.WriteLine("in input handler: " + input
            Console.WriteLine("User with ID: " + user_session.user_profile.id + " Entered: " + input);
            //get reply
            string curr_user_page = user_session.current_menu_loc;

            InputHandlerResult output = handleStdNavLinks(user_session, input);
            if (output.action != (InputHandlerResult.UNDEFINED_MENU_ACTION))
                return output;

            output = handleStdPageLinks(user_session, input);
            if (output.action != (InputHandlerResult.UNDEFINED_MENU_ACTION))
                return output;

            MenuManager mm = MenuManager.getInstance();
            //for now we assume this. must correct this later
            OptionMenuPage omp = (OptionMenuPage)mm.menu_def.getMenuPage(curr_user_page);
            List<MenuOptionItem> options = omp.options;
            foreach (MenuOptionItem option in options)
            {
                if (option.link_val.Equals(input))
                {
                    int final_input = Int32.Parse(input) - 1;
                    user_session.setVariable("ShortCode_Handler.testament_id", final_input.ToString());
                    return new InputHandlerResult(
                    InputHandlerResult.NEW_MENU_ACTION,
                    option.select_action,
                    InputHandlerResult.DEFAULT_PAGE_ID);
                }
            }
            //handle back or home here.

            return new InputHandlerResult(
                    "Invalid entry...Please enter a valid input"); //invalid choice
        }
Exemplo n.º 5
0
        protected InputHandlerResult handleDisplayMessageLinks(
            UserSession user_session,
            string input,
            String error_message,
            Boolean back_without_init)
        {
            bool message_page = user_session.getVariable(DISPLAY_MESSAGE) != null;
            if (message_page == true)
            {
                user_session.removeVariable(DISPLAY_MESSAGE);
            }

            InputHandlerResult output = handleStdNavLinks(user_session, input, back_without_init);
            if (output.action != (InputHandlerResult.UNDEFINED_MENU_ACTION))
                return output;

            //if this was a messsage then the only options is the std Nav links. any other input is invalid so reshow message
            if (message_page)
            {
                user_session.setVariable(DISPLAY_MESSAGE, "Message sent");//you must be sure to remove this from hash table in handler.
                return new InputHandlerResult(
                    InputHandlerResult.DISPLAY_MESSAGE,
                    InputHandlerResult.DEFAULT_MENU_ID, //not used
                    error_message);
            }
            else
            {
                return new InputHandlerResult(
                    InputHandlerResult.UNDEFINED_MENU_ACTION,
                    InputHandlerResult.DEFAULT_MENU_ID,
                    InputHandlerResult.DEFAULT_PAGE_ID
                    );
            }
        }
Exemplo n.º 6
0
        public override InputHandlerResult handleExtraCommandInput(UserSession us, String input)
        {
            if (getExtraCommandString() != null && getExtraCommandString() != "")
            {

              //  Boolean confirmed_delete;
                Boolean is_confirming = false;
                try
                {
                    Object o = us.removeVariable("ConfirmedHistoryDelete");
                    if (o != null)
                    {
                        is_confirming = (Boolean)o;
                    }
                    else
                    {
                        is_confirming = false;
                    }
                    /*is_confirming = true;*/
                }
                catch (Exception e)
                {
                    is_confirming = false;
                    /*is_confirming = false;*/
                }

                if (!is_confirming && CLEAR_HISTORY.Equals(input.ToUpper()))
                {
                    us.setVariable("ConfirmedHistoryDelete", true);
                    return new InputHandlerResult(
                            InputHandlerResult.CONF_PAGE_ACTION,
                            InputHandlerResult.DEFAULT_MENU_ID,
                           "Are you sure that you want to clear the history (Y/N)?");
                }
                if (is_confirming)
                {
                    if (CONFIRMED_DELETE.Equals(input.ToUpper()) || CONFIRMED_DELETE_2.Equals(input.ToUpper()))
                    {
                        us.verse_history.clearHistory(us.user_profile);
                        return new InputHandlerResult("The history has been cleared");
                    }
                    else if (CANCELLED_DELETE.Equals(input.ToUpper()) || CANCELLED_DELETE_2.Equals(input.ToUpper()))
                    {
                        return new InputHandlerResult();
                    }
                }
                if (!is_confirming)
                {
                    return new InputHandlerResult(
                           InputHandlerResult.UNDEFINED_MENU_ACTION,
                           InputHandlerResult.DEFAULT_MENU_ID,
                           InputHandlerResult.DEFAULT_PAGE_ID);
                }
            }
            return new InputHandlerResult(
                   InputHandlerResult.UNDEFINED_MENU_ACTION,
                   InputHandlerResult.DEFAULT_MENU_ID,
                   InputHandlerResult.DEFAULT_PAGE_ID);
        }
Exemplo n.º 7
0
 protected InputHandlerResult handleMessagePageLinks(
     UserSession user_session,
     string input)
 {
     string curr_user_page = user_session.current_menu_loc;
     //if(user_session.getVariable(CURRENT_THREAD_PAGE)==null)
     //    user_session.setVariable(CURRENT_THREAD_PAGE, 0);
     int current_page_id = Int32.Parse(user_session.getVariable(CURRENT_MESSAGE_THREAD));
     String entry = input.ToUpper();
     if (PREV_PAGE.Equals(entry))
     {
         user_session.setVariable(CURRENT_MESSAGE_THREAD, (current_page_id - 1).ToString());
         return new InputHandlerResult(
             InputHandlerResult.PREV_PAGE_ACTION,
             user_session.current_menu_loc,
             current_page_id - 1); //the menu id is retreived from the session in this case.
     }
     else if (NEXT_PAGE.Equals(entry))
     {
         user_session.setVariable(CURRENT_MESSAGE_THREAD, (current_page_id + 1).ToString());
         return new InputHandlerResult(
             InputHandlerResult.NEXT_PAGE_ACTION,
             user_session.current_menu_loc,
             current_page_id + 1);
     }
     else if (FIRST_PAGE.Equals(entry))
     {
         user_session.setVariable(CURRENT_MESSAGE_THREAD, "0");
         return new InputHandlerResult(
             InputHandlerResult.CHANGE_PAGE_ACTION,
             user_session.current_menu_loc,
            0);
     }
     else if (entry.StartsWith(LAST_PAGE))
     {
         int page_id = Int32.Parse(entry.Split('_')[1]);
         user_session.setVariable(CURRENT_MESSAGE_THREAD, page_id.ToString());
         return new InputHandlerResult(
             InputHandlerResult.CHANGE_PAGE_ACTION,
             user_session.current_menu_loc,
             page_id);
     }
     else
     {
         return new InputHandlerResult(
             InputHandlerResult.UNDEFINED_MENU_ACTION,
             InputHandlerResult.DEFAULT_MENU_ID,
             InputHandlerResult.DEFAULT_PAGE_ID);
     }
 }
Exemplo n.º 8
0
 protected InputHandlerResult handleBrowseLinks(
     UserSession us,
     string input)
 {
     VerseSection vs = (VerseSection)us.getVariableObject("Browse.verse_section");
     if (vs == null)
     {
         Console.WriteLine("Expected Browse.verse_section present, but not found");
         return new InputHandlerResult(
            InputHandlerResult.UNDEFINED_MENU_ACTION,
            InputHandlerResult.DEFAULT_MENU_ID,
            InputHandlerResult.DEFAULT_PAGE_ID);
     }
     Verse start_verse = vs.start_verse;
     Verse end_verse = vs.end_verse;
     if (DISPLAY_MORE.Equals(input.Trim().ToUpper()))
     {
         if (end_verse != null && end_verse.next_verse != null)
         {
             start_verse = end_verse.next_verse;
             //end_verse = getDefaultEndVerse(start_verse);
             vs = new VerseSection(start_verse, null);
             us.setVariable("Browse.verse_section", vs);
             return new InputHandlerResult(InputHandlerResult.NEW_MENU_ACTION,
                         us.current_menu_loc,
                         InputHandlerResult.DEFAULT_PAGE_ID);
         }
         else
         {
             return new InputHandlerResult(
                                InputHandlerResult.UNDEFINED_MENU_ACTION,
                                InputHandlerResult.DEFAULT_MENU_ID,
                                InputHandlerResult.DEFAULT_PAGE_ID);
         }
     }
     else if (DISPLAY_NEXT_CHAPTER.Equals(input.Trim().ToUpper()))
     {
         if (start_verse != null &&
             start_verse.chapter != null  &&
             start_verse.chapter.next_chapter != null)
         {
             start_verse = start_verse.chapter.next_chapter.getVerse(1);
             //end_verse = getDefaultEndVerse(start_verse);
             vs = new VerseSection(start_verse, null);
             us.setVariable("Browse.verse_section", vs);
             return new InputHandlerResult(InputHandlerResult.NEW_MENU_ACTION,
                         us.current_menu_loc,
                         InputHandlerResult.DEFAULT_PAGE_ID);
         }
         else
         {
             return new InputHandlerResult(
                                InputHandlerResult.UNDEFINED_MENU_ACTION,
                                InputHandlerResult.DEFAULT_MENU_ID,
                                InputHandlerResult.DEFAULT_PAGE_ID);
         }
     }
     else if (DISPLAY_PREV_CHAPTER.Equals(input.Trim().ToUpper()))
     {
         if (start_verse != null &&
             start_verse.chapter != null &&
             start_verse.chapter.prev_chapter != null)
         {
             start_verse = start_verse.chapter.prev_chapter.getVerse(1);
             //end_verse = getDefaultEndVerse(start_verse);
             vs = new VerseSection(start_verse, null);
             us.setVariable("Browse.verse_section", vs);
             return new InputHandlerResult(InputHandlerResult.NEW_MENU_ACTION,
                         us.current_menu_loc,
                         InputHandlerResult.DEFAULT_PAGE_ID);
         }
         else
         {
             return new InputHandlerResult(
                                InputHandlerResult.UNDEFINED_MENU_ACTION,
                                InputHandlerResult.DEFAULT_MENU_ID,
                                InputHandlerResult.DEFAULT_PAGE_ID);
         }
     }
     else
     {
         return new InputHandlerResult(
                   InputHandlerResult.UNDEFINED_MENU_ACTION,
                   InputHandlerResult.DEFAULT_MENU_ID,
                   InputHandlerResult.DEFAULT_PAGE_ID);
     }
 }
Exemplo n.º 9
0
        protected InputHandlerResult handleDirectVerseInput(
            UserSession us,
            string input)
        {
            try
            {
                int verse_id = -1;
                VerseSection vs = (VerseSection)us.getVariableObject("Browse.verse_section");
                if (vs == null)
                {
                    Console.WriteLine("Expected Browse.verse_section present, but not found");
                    return new InputHandlerResult(
                       InputHandlerResult.UNDEFINED_MENU_ACTION,
                       InputHandlerResult.DEFAULT_MENU_ID,
                       InputHandlerResult.DEFAULT_PAGE_ID);
                }
                if (Int32.TryParse(input, out verse_id))
                {
                    Verse curr_start_verse = vs.start_verse;
                    Verse end_verse = vs.end_verse;
                    Verse start_verse = curr_start_verse.chapter.getVerse(verse_id);

                    if (start_verse != null)
                    {
                        //end_verse = getDefaultEndVerse(start_verse);
                        end_verse = start_verse;
                        vs = new VerseSection(start_verse, end_verse);//we set end verse to distinguish browsing from direct input
                        us.setVariable("Browse.verse_section", vs);
                        us.recordVerseSelection(start_verse, end_verse);
                        return new InputHandlerResult(InputHandlerResult.NEW_MENU_ACTION,
                                    us.current_menu_loc,
                                    InputHandlerResult.DEFAULT_PAGE_ID);
                    }
                    else
                    {
                        return new InputHandlerResult(
                          InputHandlerResult.UNDEFINED_MENU_ACTION,
                          InputHandlerResult.DEFAULT_MENU_ID,
                          InputHandlerResult.DEFAULT_PAGE_ID);
                    }
                }
                else
                {
                    VerseSection vs1 = (VerseSection)us.getVariableObject("Browse.verse_section");
                    if (vs1 == null)
                    {
                        Console.WriteLine("Expected Browse.verse_section present, but not found");
                        return new InputHandlerResult(
                           InputHandlerResult.UNDEFINED_MENU_ACTION,
                           InputHandlerResult.DEFAULT_MENU_ID,
                           InputHandlerResult.DEFAULT_PAGE_ID);
                    }
                    String current_book = "";
                    String current_chapter = "";
                    input = input.Replace(".", ":");
                    if(vs1 != null && vs1.start_verse != null)
                    {
                        current_book = vs1.start_verse.book.name;
                        current_chapter = vs1.start_verse.chapter.chapter_id.ToString(); // TODO: check the taking of chapter from start verse and not end verse
                    }
                    VerseSection vsection = Verse_Handler.getVerseSection(us, input, current_book, current_chapter);
                    if (vsection != null)
                    {
                        us.setVariable("Browse.verse_section", vsection);
                        Verse start_verse = vsection.start_verse;
                        Verse end_verse = vsection.end_verse;
                        us.recordVerseSelection(start_verse, end_verse);
                        return new InputHandlerResult(
                            InputHandlerResult.NEW_MENU_ACTION,
                            us.current_menu_loc,
                            InputHandlerResult.DEFAULT_PAGE_ID);
                    }
                    else
                    {
                        return new InputHandlerResult(
                          InputHandlerResult.UNDEFINED_MENU_ACTION,
                          InputHandlerResult.DEFAULT_MENU_ID,
                          InputHandlerResult.DEFAULT_PAGE_ID);
                    }
                }

            }
            catch (Exception e)
            {
                return new InputHandlerResult(
                          InputHandlerResult.UNDEFINED_MENU_ACTION,
                          InputHandlerResult.DEFAULT_MENU_ID,
                          InputHandlerResult.DEFAULT_PAGE_ID);
            }
        }
Exemplo n.º 10
0
        public override InputHandlerResult handleInput(UserSession user_session, MessageReceived message_recieved)
        {
            string input = extractReply(message_recieved);
            //Console.WriteLine("in input handler: " + input);
            Console.WriteLine("User with ID: " + user_session.user_profile.id + " Entered: " + input);
            //get reply
            string curr_user_page = user_session.current_menu_loc;

            InputHandlerResult output = handleStdNavLinks(user_session, input);
            if (output.action != (InputHandlerResult.UNDEFINED_MENU_ACTION))
                return output;

            MenuManager mm = MenuManager.getInstance();
            //for now we assume this. must correct this later
            VerseMenuPage vmp = (VerseMenuPage)mm.menu_def.getMenuPage(curr_user_page);
            List<MenuOptionItem> options = vmp.options;
            foreach (MenuOptionItem option in options)
            {
                if (option.link_val.Equals(input))
                    return new InputHandlerResult(
                         InputHandlerResult.NEW_MENU_ACTION,
                         option.select_action,
                         InputHandlerResult.DEFAULT_PAGE_ID);
            }

            //now handle input
            input = input.Trim();
            if (input.Equals(""))
            {
                return new InputHandlerResult(
            "Invalid entry...Please enter a valid input (e.g. 'John 3:16' or '1 John 1:9' or read the help section for more information"); //invalid choice
            }
            input = input.Replace('.', ':');
            Verse start_verse = null;
            Verse end_verse = null;
            if (input.Contains('-'))
            {
                String[] start_end = input.Split('-');

                start_verse = getStartingVerse(user_session.user_profile.getDefaultTranslationId(), start_end[0]);
                if (start_verse == null)
                {
                    return new InputHandlerResult(
                                "Invalid entry...Please enter a valid input (e.g. 'John 3:16' or '1 John 1:9'"); //invalid choice
                }
                if (start_end.Count() >= 2)
                {
                    end_verse = getEndingVerse(user_session.user_profile.getDefaultTranslationId(), start_verse, start_end[1]);
                }
            }
            else
            {
                start_verse = getStartingVerse(user_session.user_profile.getDefaultTranslationId(), input);
            }
            user_session.deleteVariable("Browse.verse_section");

            try
            {
                if (end_verse == null)
                    end_verse = start_verse;
                VerseSection vs = new VerseSection(start_verse, end_verse);
                user_session.setVariable("Browse.verse_section", vs);
                //now this is one big hack
                user_session.setVariable("Browse.directSelect", true);
            }
            catch (XInvalidVerseSection e)
            {
                return new InputHandlerResult(e.Message); //invalid choice
            }

            return new InputHandlerResult(
                     InputHandlerResult.NEW_MENU_ACTION,
                     vmp.input_item.target_page,
                     InputHandlerResult.DEFAULT_PAGE_ID);
        }
Exemplo n.º 11
0
        public override void init(UserSession us)
        {
            //Console.WriteLine("Init Browse Interaction");
            //first we need a way to know if the screen should be cleared.
            us.setVariable(BROWSE_CLEAR_SCREEN, true);
            //now this is one big hack
            Boolean direct_select;
            try
            {
                Object o = us.removeVariable("Browse.directSelect");
                if(o==null)
                    direct_select = false;
                else
                    direct_select = (Boolean)o;
            }catch(Exception e)
            {
                direct_select = false;
            }

            int verse_history_index = getVerseHistoryIndex(us);

            //Verse was selected from history of verses
            if (verse_history_index > -1)
            {
                ReadOnlyCollection<VerseHistoryRecord> history_list = us.verse_history.getHistoryListForDisplay();
                VerseHistoryRecord vhr = history_list[verse_history_index];
                Verse start_verse = Verse_Handler.getStartingVerse(us.user_profile.getDefaultTranslationId(), vhr.start_verse);
                Verse end_verse;
                if (vhr.end_verse == null || vhr.start_verse.Equals(vhr.end_verse))
                    end_verse = start_verse;
                else if ("NULL".Equals(vhr.end_verse))
                    end_verse = BrowseBibleScreenOutputAdapter.getDefaultEndVerse(start_verse);
                else
                    end_verse = Verse_Handler.getStartingVerse(us.user_profile.getDefaultTranslationId(), vhr.end_verse);

                VerseSection vs = new VerseSection(start_verse, end_verse);
                us.setVariable("Browse.verse_section", vs);
            }
            else
            {
                String top_fav_verse = getTopFavouriteSelectedVerse(us);
                if (top_fav_verse != null)
                {
                    VerseSection vs = Verse_Handler.getVerseSection(us, top_fav_verse, null, null);
                    if (vs != null)
                    {
                        us.setVariable("Browse.verse_section", vs);
                        us.recordVerseSelection(vs.start_verse, vs.end_verse);
                    }
                }
                else
                {
                    int fav_verse_index = getFavouriteVerseIndex(us);

                    //Verse was selected from history of verses
                    if (fav_verse_index > -1)
                    {
                        ReadOnlyCollection<FavouriteVerseRecord> favourite_list = us.favourite_verses.getFavouriteListForDisplay();
                        FavouriteVerseRecord fvr = favourite_list[fav_verse_index];
                        Verse start_verse = Verse_Handler.getStartingVerse(us.user_profile.getDefaultTranslationId(), fvr.start_verse);
                        Verse end_verse;
                        if (fvr.end_verse == null || fvr.start_verse.Equals(fvr.end_verse))
                            end_verse = start_verse;
                        else if ("NULL".Equals(fvr.end_verse))
                            end_verse = BrowseBibleScreenOutputAdapter.getDefaultEndVerse(start_verse);
                        else
                            end_verse = Verse_Handler.getStartingVerse(us.user_profile.getDefaultTranslationId(), fvr.end_verse);

                        VerseSection vs = new VerseSection(start_verse, end_verse);
                        us.setVariable("Browse.verse_section", vs);
                        us.recordVerseSelection(vs.start_verse, vs.end_verse);
                    }
                    else{
                        String bookmark_verse = getBookmarkVerse(us);
                        if (bookmark_verse != null)
                        {
                            VerseSection vs = Verse_Handler.getVerseSection(us, bookmark_verse, null, null);
                            if (vs != null)
                            {
                                us.setVariable("Browse.verse_section", vs);
                                us.recordVerseSelection(vs.start_verse, vs.end_verse);
                            }
                        }
                        else
                        {
                            String daily_verse = getDailyVerseSelected(us);
                            if (daily_verse != null)
                            {
                                VerseSection vs = Verse_Handler.getVerseSection(us, daily_verse, null, null);
                                if (vs != null)
                                {
                                    us.setVariable("Browse.verse_section", vs);
                                    us.recordVerseSelection(vs.start_verse, vs.end_verse);
                                }
                            }
                            else
                            {
                                String topic_verse = getTopicVerse(us);
                                if (topic_verse != null)
                                {
                                    VerseSection vs = Verse_Handler.getVerseSection(us, topic_verse, null, null);
                                    if (vs != null)
                                    {
                                        us.setVariable("Browse.verse_section", vs);
                                        us.recordVerseSelection(vs.start_verse, vs.end_verse);
                                    }
                                }
                                else
                                {
                                    String search_verse = getSearchVerse(us);
                                    if (search_verse != null)
                                    {
                                        int search_verse_index = Int32.Parse(search_verse) - 1;
                                        SearchVerseRecord svr = us.search_results[search_verse_index];
                                        Verse start_verse = Verse_Handler.getStartingVerse(us.user_profile.getDefaultTranslationId(), svr.start_verse);
                                        VerseSection vs = new VerseSection(start_verse, start_verse);
                                        if (vs != null)
                                        {
                                            us.setVariable("Browse.verse_section", vs);
                                            us.recordVerseSelection(start_verse, start_verse);
                                        }
                                    }
                                    //verse was selected from direct select
                                    else if (direct_select == false)
                                    {

                                        Verse start_verse = BibleContainer.getInstance().getVerse(
                                                Int32.Parse(us.user_profile.getDefaultTranslationId()),
                                                Int32.Parse(us.getVariable("Testament_Handler.testament_id")),
                                                us.getVariable("BookOptionSet.book_id"),
                                                Int32.Parse(us.getVariable("ChapterOptionSet.chapter_id")),
                                                1);
                                        VerseSection vs = new VerseSection(start_verse, null);
                                        us.setVariable("Browse.verse_section", vs);
                                        us.recordVerseSelection(start_verse, null);
                                    }
                                    //Verse was selected by browsing
                                    else
                                    {
                                        VerseSection vs = (VerseSection)us.getVariableObject("Browse.verse_section");
                                        if (vs == null)
                                        {
                                            Console.WriteLine("Warning...verse_section context var was not found");
                                            throw new Exception("Expected Browse.verse_section var present but not found");
                                        }
                                        Verse start_verse = vs.start_verse;
                                        Verse end_verse = vs.end_verse;
                                        us.recordVerseSelection(start_verse, end_verse);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 12
0
        public override InputHandlerResult handleInput(UserSession user_session, MessageReceived message_recieved)
        {
            string input = extractReply(message_recieved);
            Console.WriteLine("User with ID: " + user_session.user_profile.id + " Entered: " + input);
            //get reply
            string curr_user_page = user_session.current_menu_loc;

            MenuManager mm = MenuManager.getInstance();
            MenuPage mp = mm.menu_def.getMenuPage(curr_user_page);
            //for now we assume this. must correct this later
            DynMenuPage dmp = (DynMenuPage)mm.menu_def.getMenuPage(curr_user_page);

            //handle extra commands
            InputHandlerResult output = dmp.dynamic_set.handleExtraCommandInput(user_session, input);
            if (output.action != (InputHandlerResult.UNDEFINED_MENU_ACTION))
                return output;

            output = handleStdNavLinks(user_session, input);
            if (output.action != (InputHandlerResult.UNDEFINED_MENU_ACTION))
                return output;

            output = handleStdPageLinks(user_session, input);
            if (output.action != (InputHandlerResult.UNDEFINED_MENU_ACTION))
                return output;

            List<MenuOptionItem> options = mp.getOptionList(user_session);
            string output_var = dmp.output_var;
            //this is a waste, if we do change input then its found so we can already return.
            input = dmp.dynamic_set.parseInput(input, user_session);
            foreach (MenuOptionItem option in options)
            {
                if (option.is_valid && (option.link_val.Equals(input) || option.menu_option_id.Equals(input)))
                {

                    user_session.setVariable(output_var, input);
                    return new InputHandlerResult(
                        InputHandlerResult.NEW_MENU_ACTION,
                        option.select_action,
                        InputHandlerResult.DEFAULT_PAGE_ID);
                }
            }

            /*else if (mp.GetType().Name == "MxitTestApp.OptionMenuPage")
            {
                OptionMenuPage omp = (OptionMenuPage)mm.menu_def.getMenuPage(curr_user_page);
                List<MenuOptionItem> options = omp.options;
                foreach (MenuOptionItem option in options)
                {
                    if (option.link_val.Equals(input))
                    {
                        user_session.setVariable("SELECTED_BOOK_ID", input);
                        return new InputHandlerResult(
                            InputHandlerResult.NEW_MENU_ACTION,
                            option.select_action,
                            InputHandlerResult.DEFAULT_PAGE_ID);
                    }
                }
            }*/

            //handle back or home here.

            return new InputHandlerResult(
                    "Invalid entry...Please enter a valid input"); //invalid choice
        }
Exemplo n.º 13
0
 public Boolean displayMessage(UserSession us, MessageToSend ms, InputHandlerResult ihr)
 {
     if (ihr.action == InputHandlerResult.DISPLAY_MESSAGE)
     {
         ms.Append(MessageBuilder.Elements.CreateClearScreen());
         ms.Append(ihr.message + "\r\n");
         appendBackMainLinks(us, ms);
         appendMessageConfig(true, ms);
         us.setVariable(AInputHandler.DISPLAY_MESSAGE , "Message sent");//you must be sure to remove this from hash table in handler.
         return true;
     }
     return false;
 }
Exemplo n.º 14
0
        /*this method either returns the new screen id or the main or prev command string*/
        protected InputHandlerResult handleFriendLinks(
            UserSession user_session,
            string input)
        {
            string curr_user_page = user_session.current_menu_loc;
            String entry = input.ToUpper();
            long friend_id = -1;
            if (entry.StartsWith(BLOCK_FRIEND))
            {
                user_session.setVariable(ORIGINAL_ACTION, entry);
                friend_id = long.Parse(entry.Split('_')[1]);
                String user_name = UserNameManager.getInstance().getUserName(friend_id);

                return new InputHandlerResult(
                    InputHandlerResult.CONF_PAGE_ACTION,
                    InputHandlerResult.DEFAULT_MENU_ID,
                   "Are you sure that you want block " + user_name +"?");
            }
            else if (entry.StartsWith(DELETE_FRIEND))
            {
                user_session.setVariable(ORIGINAL_ACTION, entry);
                friend_id = long.Parse(entry.Split('_')[1]);
                String user_name = UserNameManager.getInstance().getUserName(friend_id);

                return new InputHandlerResult(
                    InputHandlerResult.CONF_PAGE_ACTION,
                    InputHandlerResult.DEFAULT_MENU_ID,
                   "Are you sure that you want remove " + user_name + " from your buddy list?");
            }
            if (entry.ToUpper().Equals(CONF_YES) || entry.ToUpper().Equals(CONF_Y))
            {
                String original_action = user_session.getVariable(ORIGINAL_ACTION);
                if(original_action != null)
                {
                    user_session.removeVariable(ORIGINAL_ACTION);
                    if (original_action.StartsWith(BLOCK_FRIEND))
                    {
                        friend_id = long.Parse(original_action.Split('_')[1]);
                        String user_name = UserNameManager.getInstance().getUserName(friend_id);
                        user_session.friend_manager.blockFriend(friend_id);
                        user_session.setVariable(BLOCKED_FRIEND_NAME, user_name);
                    }else if(original_action.StartsWith(DELETE_FRIEND))
                    {
                        friend_id = long.Parse(original_action.Split('_')[1]);
                        user_session.friend_manager.deleteFriendRequest(friend_id);
                        String user_name = UserNameManager.getInstance().getUserName(friend_id);
                        user_session.setVariable(DELETED_FRIEND_NAME, user_name);
                    }

                    return new InputHandlerResult(
                        InputHandlerResult.BACK_MENU_ACTION,
                        InputHandlerResult.DEFAULT_MENU_ID,
                        InputHandlerResult.DEFAULT_PAGE_ID); //the menu id is retreived from the session in this case.
                }
                return new InputHandlerResult(
                    InputHandlerResult.UNDEFINED_MENU_ACTION,
                    InputHandlerResult.DEFAULT_MENU_ID,
                    InputHandlerResult.DEFAULT_PAGE_ID);
            }
            else if (entry.ToUpper().Equals(CONF_NO) || entry.ToUpper().Equals(CONF_N))
            {
                    String original_action = user_session.getVariable(ORIGINAL_ACTION);
                    if(original_action != null)
                    {
                        user_session.removeVariable(ORIGINAL_ACTION);
                    }
                    return new InputHandlerResult(
                        InputHandlerResult.DO_NOTHING_ACTION,
                        InputHandlerResult.DEFAULT_MENU_ID,
                        InputHandlerResult.DEFAULT_PAGE_ID);
            }
            else if (entry.StartsWith(FILTER_LIST))
            {
                String filter = entry.Split('_')[1];
                user_session.setVariable(FRIEND_LIST_FILTER, filter);

                    return new InputHandlerResult(
                        InputHandlerResult.DO_NOTHING_ACTION,
                        InputHandlerResult.DEFAULT_MENU_ID,
                        InputHandlerResult.DEFAULT_PAGE_ID);
            }
            else
            {
                String original_action = user_session.getVariable(ORIGINAL_ACTION);
                if (original_action != null)
                {
                    user_session.removeVariable(ORIGINAL_ACTION);
                }
                return new InputHandlerResult(
                    InputHandlerResult.UNDEFINED_MENU_ACTION,
                    InputHandlerResult.DEFAULT_MENU_ID,
                    InputHandlerResult.DEFAULT_PAGE_ID);
            }
        }
Exemplo n.º 15
0
 protected InputHandlerResult handleReferLink(
     UserSession us,
     string input)
 {
     if (REFER_A_FRIEND.Equals(input.Trim().ToUpper()))
     {
         us.setVariable(REFER_A_FRIEND, REFER_A_FRIEND);
         return new InputHandlerResult(
                      InputHandlerResult.DO_NOTHING_ACTION,
                      InputHandlerResult.DEFAULT_MENU_ID,
                      InputHandlerResult.DEFAULT_PAGE_ID);
     }
     else
     {
         return new InputHandlerResult(
                      InputHandlerResult.UNDEFINED_MENU_ACTION,
                      InputHandlerResult.DEFAULT_MENU_ID,
                      InputHandlerResult.DEFAULT_PAGE_ID);
     }
 }
Exemplo n.º 16
0
        protected InputHandlerResult handleBookmarkLinks(
            UserSession us,
            string input)
        {
            if (BOOKMARK_ENTERED.Equals(input.Trim().ToUpper()))
            {
                BookmarkVerseRecord bvr = us.bookmark_manager.bookmark_verse;
                if (bvr == null)
                {
                    //we should never get here, the bookmark should not be available if the user has not browsed before, but just in case :)
                    return new InputHandlerResult(
                                    "You do not currently have a bookmark set, please choose something else. if you have been browsing the Bible before this, then you should have one. Let us know if that is the case so we can look into it.");
                }
                Verse start_verse = Verse_Handler.getStartingVerse(us.user_profile.getDefaultTranslationId(), bvr.start_verse);
                Verse end_verse;
                if (bvr.end_verse == null || bvr.start_verse.Equals(bvr.end_verse))
                    end_verse = null;
                else if ("NULL".Equals(bvr.end_verse))
                    end_verse = BrowseBibleScreenOutputAdapter.getDefaultEndVerse(start_verse);
                else
                    end_verse = Verse_Handler.getStartingVerse(us.user_profile.getDefaultTranslationId(), bvr.end_verse);

                String verse_ref = BibleHelper.getVerseSectionReferenceWithoutTranslation(start_verse, end_verse);
                us.setVariable(BOOKMARK_VERSE_VAR_NAME, verse_ref);

                return new InputHandlerResult(
                             InputHandlerResult.NEW_MENU_ACTION,
                             MenuIDConstants.BROWSE_MENU_ID,
                             InputHandlerResult.DEFAULT_PAGE_ID);

            }
            return new InputHandlerResult(
                         InputHandlerResult.UNDEFINED_MENU_ACTION,
                         InputHandlerResult.DEFAULT_MENU_ID,
                         InputHandlerResult.DEFAULT_PAGE_ID);
        }
Exemplo n.º 17
0
        /*this method either returns the new screen id or the main or prev command string*/
        protected InputHandlerResult handleMessageInboxLinks(
            UserSession user_session,
            string input)
        {
            string curr_user_page = user_session.current_menu_loc;
            String entry = input.ToUpper();
            String thread_id = "";
            long t_id = -1;
            if (entry.StartsWith(OPEN_THREAD))
            {
                thread_id = entry.Split('_')[1];
                user_session.setVariable(CURRENTLY_VIEWING_TRHEAD, thread_id);

                return new InputHandlerResult(
                    InputHandlerResult.NEW_MENU_ACTION,
                    MenuIDConstants.VIEW_THREAD_ID,
                    InputHandlerResult.DEFAULT_PAGE_ID);
            }
            else if (entry.StartsWith(DELETE_THREAD))
            {
                user_session.setVariable(ORIGINAL_ACTION, entry);
                return new InputHandlerResult(
                    InputHandlerResult.CONF_PAGE_ACTION,
                    InputHandlerResult.DEFAULT_MENU_ID,
                   "Are you sure that you want remove this message from your inbox?");
            }
            if (entry.ToUpper().Equals(CONF_YES) || entry.ToUpper().Equals(CONF_Y))
            {
                String original_action = user_session.getVariable(ORIGINAL_ACTION);
                if (original_action != null)
                {
                    user_session.removeVariable(ORIGINAL_ACTION);
                    if (original_action.StartsWith(DELETE_THREAD))
                    {
                        t_id= long.Parse(original_action.Split('_')[1]);
                        VerseMessageThread vmt = VerseThreadManager.getInstance().getVerseMessageThread(t_id);
                        if(vmt != null)
                        {
                            user_session.verse_messaging_manager.removeParticipantFromThread(vmt);
                            return new InputHandlerResult("Message Deleted..");
                        }
                        else{
                            return new InputHandlerResult("Something went wrong when attempting to delete the message from your inbox. Please let us know so that we can look into the issue.");
                        }
                    }

                    return new InputHandlerResult(
                        InputHandlerResult.BACK_MENU_ACTION,
                        InputHandlerResult.DEFAULT_MENU_ID,
                        InputHandlerResult.DEFAULT_PAGE_ID); //the menu id is retreived from the session in this case.
                }
                return new InputHandlerResult(
                    InputHandlerResult.UNDEFINED_MENU_ACTION,
                    InputHandlerResult.DEFAULT_MENU_ID,
                    InputHandlerResult.DEFAULT_PAGE_ID);
            }
            else if (entry.ToUpper().Equals(CONF_NO) || entry.ToUpper().Equals(CONF_N))
            {
                String original_action = user_session.getVariable(ORIGINAL_ACTION);
                if (original_action != null)
                {
                    user_session.removeVariable(ORIGINAL_ACTION);
                }
                return new InputHandlerResult(
                    InputHandlerResult.DO_NOTHING_ACTION,
                    InputHandlerResult.DEFAULT_MENU_ID,
                    InputHandlerResult.DEFAULT_PAGE_ID);
            }
            else if (entry.ToUpper().Equals(REFRESH_INBOX))
            {
                return new InputHandlerResult(
                    InputHandlerResult.DO_NOTHING_ACTION,
                    InputHandlerResult.DEFAULT_MENU_ID,
                    user_session.current_menu_page);
            }
            return new InputHandlerResult(
                InputHandlerResult.UNDEFINED_MENU_ACTION,
                InputHandlerResult.DEFAULT_MENU_ID,
                InputHandlerResult.DEFAULT_PAGE_ID);
        }
Exemplo n.º 18
0
 public override void init(UserSession us)
 {
     us.setVariable(CURRENT_MESSAGE_THREAD, "0");
 }
        public override InputHandlerResult handleInput(UserSession user_session, MessageReceived message_recieved)
        {
            string input = extractReply(message_recieved);
            Console.WriteLine("User with ID: " + user_session.user_profile.id + " Entered: " + input);
            //get reply
            string curr_user_page = user_session.current_menu_loc;
            InputHandlerResult output = handleDisplayMessageLinks(
                user_session,
                input,
                "Your input was invalid.Your subject has been set already...please click Back/Main to continue",
                true);
            if (output.action != (InputHandlerResult.UNDEFINED_MENU_ACTION))
                return output;

            output = handleStdNavLinks(user_session, input,true);
            if (output.action != (InputHandlerResult.UNDEFINED_MENU_ACTION))
                return output;

            /*output = handleStdPageLinks(user_session, input);
            if (output.action != (InputHandlerResult.UNDEFINED_MENU_ACTION))
                return output;*/

            MenuManager mm = MenuManager.getInstance();
            //for now we assume this. must correct this later
            VerseMenuPage vmp = (VerseMenuPage)mm.menu_def.getMenuPage(curr_user_page);
            List<MenuOptionItem> options = vmp.options;
            foreach (MenuOptionItem option in options)
            {
                if (option.link_val.Equals(input))
                    return new InputHandlerResult(
                         InputHandlerResult.NEW_MENU_ACTION,
                         option.select_action,
                         InputHandlerResult.DEFAULT_PAGE_ID);
            }

            if (input.Count() > MAX_MESSAGE_LENGTH)
            {
                return new InputHandlerResult(
                   "Your subject is too long, please keep it less than " + MAX_MESSAGE_LENGTH + " characters.\r\n"); //invalid choice
            }
            else if (input.Trim().Equals(""))
            {
                return new InputHandlerResult(
                   "You entered a blank subject. please try again.\r\n"); //blank input
            }
            else
            {
                try
                {
                    user_session.setVariable(
                        VerseMessageSendOutputAdapter.MESSAGE_SUBJECT,
                        input);

                    return new InputHandlerResult(
                        InputHandlerResult.BACK_WITHOUT_INIT_MENU_ACTION,
                        InputHandlerResult.DEFAULT_MENU_ID,
                        InputHandlerResult.DEFAULT_PAGE_ID);
                    /*return new InputHandlerResult(
                     InputHandlerResult.DISPLAY_MESSAGE,
                     InputHandlerResult.DEFAULT_MENU_ID, //not used
                    "Your Subject has been set...Please choose Back to continue sending the message. ");*/
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.StackTrace);
                    return new InputHandlerResult(
                   "Something went wrong when trying to send your message, please try again later. "); //invalid choice
                }
            }
        }
Exemplo n.º 20
0
        public override InputHandlerResult handleInput(UserSession user_session, MessageReceived message_recieved)
        {
            string input = extractReply(message_recieved);
            Console.WriteLine("User with ID: " + user_session.user_profile.id + " Entered: " + input);
            //get reply
            string curr_user_page = user_session.current_menu_loc;
            InputHandlerResult output = handleDisplayMessageLinks(
                user_session,
                input,
                "Your input was invalid. You message has been sent already but please click Back/Main to continue");

            if (output.action != (InputHandlerResult.UNDEFINED_MENU_ACTION))
                return output;

            output = handleStdNavLinks(user_session, input);
            if (output.action != (InputHandlerResult.UNDEFINED_MENU_ACTION))
                return output;

            /*output = handleStdPageLinks(user_session, input);
            if (output.action != (InputHandlerResult.UNDEFINED_MENU_ACTION))
                return output;*/

            MenuManager mm = MenuManager.getInstance();
            //for now we assume this. must correct this later
            VerseMenuPage vmp = (VerseMenuPage)mm.menu_def.getMenuPage(curr_user_page);
            List<MenuOptionItem> options = vmp.options;
            foreach (MenuOptionItem option in options)
            {
                if (option.link_val.Equals(input))
                    return new InputHandlerResult(
                         InputHandlerResult.NEW_MENU_ACTION,
                         option.select_action,
                         InputHandlerResult.DEFAULT_PAGE_ID);
            }
            long id = -1;
            if (!long.TryParse(input,out id))
            {
                return new InputHandlerResult(
                   "You have to enter the numeric profile ID of the recipient."); //invalid choice
            }
            else if (input.Trim().Equals(""))
            {
                return new InputHandlerResult(
                   "You entered a blank message. please try again.\r\n"); //blank input
            }
            else
            {
                try
                {

                    user_session.setVariable(NotifMessageSendOutputAdapter.RECIPIENT_ID, id.ToString());

                    return new InputHandlerResult(
                        InputHandlerResult.BACK_WITHOUT_INIT_MENU_ACTION,
                        InputHandlerResult.DEFAULT_MENU_ID,
                        InputHandlerResult.DEFAULT_PAGE_ID);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.StackTrace);
                    return new InputHandlerResult(
                   "Something went wrong when trying to send your message, please try again later. "); //invalid choice
                }
            }
        }