Esempio n. 1
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
                    );
            }
        }
Esempio n. 2
0
 /*returns -1 if there favourite option wasnt chosen*/
 public int getFavouriteVerseIndex(UserSession us)
 {
     try
     {
         Object o = us.removeVariable("FavouriteVersesOptionSet.verse_from_favourites");
         if (o == null)
             return -1;
         int fav_verse_index = Int32.Parse((String)o);
         return fav_verse_index - 1;
     }
     catch (Exception e)
     {
         return -1;
     }
 }
Esempio n. 3
0
 /*returns null if the bookmark option wasnt chosen*/
 public String getDailyVerseSelected(UserSession us)
 {
     try
     {
         Object o = us.removeVariable("DailyVerseOptionSet.daily_verse_selected");
         if (o == null)
             return null;
         String search_verse = (String)o;
         return search_verse;
     }
     catch (Exception e)
     {
         return null;
     }
 }
Esempio n. 4
0
 /*returns null if the bookmark option wasnt chosen*/
 public String getBookmarkVerse(UserSession us)
 {
     try
     {
         Object o = us.removeVariable(MainMenuHandler.BOOKMARK_VERSE_VAR_NAME);
         if (o == null)
             return null;
         String bookmark_verse = (String)o;
         return bookmark_verse;
     }
     catch (Exception e)
     {
         return null;
     }
 }
 public override void init(UserSession us)
 {
     if (us.hasVariable(VerseMessageSendOutputAdapter.MESSAGE_SUBJECT))
     {
         us.deleteVariable(VerseMessageSendOutputAdapter.MESSAGE_SUBJECT);
     }
     if (us.hasVariable(VerseMessageSendOutputAdapter.FRIEND_TO_SEND_ID))
     {
         us.deleteVariable(VerseMessageSendOutputAdapter.FRIEND_TO_SEND_ID);
     }
     if (us.hasVariable(VerseMessageSendOutputAdapter.MESSAGE_TEXT))
     {
         us.deleteVariable(VerseMessageSendOutputAdapter.MESSAGE_TEXT);
     }
     if (us.hasVariable(ChooseFriendHandler.RECIPIENT_LIST))
     {
         us.deleteVariable(ChooseFriendHandler.RECIPIENT_LIST);
     }
     if (us.hasVariable(ChooseFriendHandler.RECIPIENT_LIST))
         us.removeVariable(ChooseFriendHandler.RECIPIENT_LIST);
 }
Esempio 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);
        }
Esempio n. 7
0
 /*returns null if the bookmark option wasnt chosen*/
 public String getSearchVerse(UserSession us)
 {
     try
     {
         Object o = us.removeVariable(SearchHandler.SEARCH_VERSE_VAR_NAME);
         if (o == null)
             return null;
         String search_verse = (String)o;
         return search_verse;
     }
     catch (Exception e)
     {
         return null;
     }
 }
Esempio n. 8
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);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 9
0
        /*returns -1 if there history option wasnt chosen*/
        public int getVerseHistoryIndex(UserSession us)
        {
            // we assume that if the session variable MxitTestApp.VerseHistoryOptionSet exists then history
            // verse was selected.
            try
            {
                Object o = us.removeVariable("VerseHistoryOptionSet.verse_from_history");
                if (o == null)
                    return -1;
                int verse_history_index = Int32.Parse((String)o);
                return verse_history_index - 1;
            }
            catch (Exception e)
            {
                return -1;

            }
        }
Esempio n. 10
0
 /*returns null if the bookmark option wasnt chosen*/
 public String getTopicVerse(UserSession us)
 {
     try
     {
         Object o = us.removeVariable("Bible_Topic.topic_id");
         if (o == null)
             return null;
         String verse_ref = (String)o;
         return verse_ref;
     }
     catch (Exception e)
     {
         return null;
     }
 }
Esempio n. 11
0
 /*returns null if there favourite option wasnt chosen*/
 public String getTopFavouriteSelectedVerse(UserSession us)
 {
     try
     {
         Object o = us.removeVariable("TopFavouriteVersesOptionSet.verse_from_top_favourites");
         if (o == null)
             return null;
         String top_fav_verse = (String)o;
         return top_fav_verse;
     }
     catch (Exception e)
     {
         return null;
     }
 }
Esempio n. 12
0
 public override void init(UserSession us)
 {
     Object curr_page = us.getVariableObject(TAGGED_VERSE_CURRENT_PAGE);
     if (curr_page != null)
     {
         int curr_page_i = (int)curr_page;
         us.removeVariable(TAGGED_VERSE_CURRENT_PAGE);
         us.current_menu_page = curr_page_i;
     }
 }
Esempio n. 13
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);
            }
        }
Esempio n. 14
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);
        }