note description: "API interface to user services" author: "Rafael Bischof " date: "$Date$" revision: "$Revision$" class USER_SERVICE inherit API_SERVICE create make feature -- Basic operations user_my_name (a_session: STRING): STRING -- Return username of user associated with a_session local l_msg: O_USER_MY_NAME_MESSAGE l_string_msg: A_GENERAL_STRING_MESSAGE do Result := "" -- argument validiation check_anonymous_session (a_session) if not is_valid_session (a_session) then last_fault := err_invalid_session else -- generate and send message create l_msg.make (create {A_STRING_VALUE}.make (a_session)) send_and_wait_for_reply (l_msg) if is_ok then l_string_msg ?= last_reply check string_message: l_string_msg /= Void end Result := l_string_msg.string.value end end end user_my_password (a_session: STRING): STRING -- Return password of user associated with a_session local l_msg: O_USER_MY_PASSWORD_MESSAGE l_string_msg: A_GENERAL_STRING_MESSAGE do Result := "" -- argument validiation check_anonymous_session (a_session) if not is_valid_session (a_session) then last_fault := err_invalid_session else -- generate and send message create l_msg.make (create {A_STRING_VALUE}.make (a_session)) send_and_wait_for_reply (l_msg) if is_ok then l_string_msg ?= last_reply check string_message: l_string_msg /= Void end Result := l_string_msg.string.value end end end user_my_email (a_session: STRING): STRING -- Return email of user associated with a_session. local l_msg: O_USER_MY_EMAIL_MESSAGE l_string_msg: A_GENERAL_STRING_MESSAGE do Result := "" -- argument validiation check_anonymous_session (a_session) if not is_valid_session (a_session) then last_fault := err_invalid_session else -- generate and send message create l_msg.make (create {A_STRING_VALUE}.make (a_session)) send_and_wait_for_reply (l_msg) if is_ok then l_string_msg ?= last_reply check string_message: l_string_msg /= Void end Result := l_string_msg.string.value end end end user_profile_visible (a_user_name: STRING): DS_HASH_TABLE [ANY, STRING] -- Returns 0 if not visible for anonymous users, otherwise value > 0. local l_reply_msg: A_GENERAL_STRING_MESSAGE l_msg: O_USER_PROFILE_VISIBLE_MESSAGE i: INTEGER iref: INTEGER_REF do if a_user_name = Void or else a_user_name.is_empty then last_fault := err_invalid_name else -- generate and send message create l_msg.make (create {A_STRING_VALUE}.make (a_user_name)) send_and_wait_for_reply (l_msg) if is_ok then l_reply_msg ?= last_reply check message: l_reply_msg /= Void end i := l_reply_msg.string.value.to_integer -- decode integer and create hash table create Result.make (3) create iref iref.set_item(i.bit_and (1)) Result.force (iref, "profile_visible") -- create iref -- iref.set_item (i.bit_and (2).bit_shift_right (1)) -- Result.force (iref, "foaf_visible") create iref iref.set_item (i.bit_and (4).bit_shift_right (2)) Result.force (iref, "sha1mbox_visible") create iref iref.set_item (i) Result.force (iref, "encoded") end end end user_change_profile_visible (a_session: STRING; a_value: INTEGER_REF): BOOLEAN_REF -- Sets the profile visibility local l_msg: O_USER_CHANGE_PROFILE_VISIBLE_MESSAGE do -- argument validation check_anonymous_session (a_session) if not is_valid_session (a_session) then last_fault := err_invalid_session elseif a_value = Void or else a_value.item < 0 then last_fault := err_invalid_information else -- generate and send message create l_msg.make (create {A_STRING_VALUE}.make (a_session), create {A_INTEGER_VALUE}.make (a_value.item)) send_and_wait_for_reply (l_msg) if is_ok then create Result Result.set_item (True) else create Result Result.set_item (False) end end end user_retrieve_information (a_session: STRING; a_user_name: STRING): DS_HASH_TABLE [ANY, STRING] -- Retrieve user information of user with name user_name. local l_msg: O_USER_RETRIEVE_INFORMATION_MESSAGE l_user_information_reply_msg: O_USER_RETRIEVE_INFORMATION_REPLY_MESSAGE l_int_ref: INTEGER_REF l_double_ref: DOUBLE_REF l_string_map: DS_HASH_TABLE [A_STRING_VALUE, A_STRING_VALUE] l_integer_map: DS_HASH_TABLE [A_INTEGER_VALUE, A_STRING_VALUE] l_double_map: DS_HASH_TABLE [A_DOUBLE_VALUE, A_STRING_VALUE] do -- argument validiation check_anonymous_session (a_session) if not is_valid_session (a_session) then last_fault := err_invalid_session elseif a_user_name = Void or else a_user_name.is_empty then last_fault := err_invalid_name else -- generate and send message create l_msg.make (a_session, a_user_name) send_and_wait_for_reply (l_msg) if is_ok then l_user_information_reply_msg ?= last_reply check user_information_reply_message: l_user_information_reply_msg /= Void end create Result.make (2) Result.force (a_user_name, "user_name") -- Add user data -- strings l_string_map := l_user_information_reply_msg.string_settings.map from l_string_map.start until l_string_map.after loop Result.force(l_string_map.item_for_iteration.value, l_string_map.key_for_iteration.value) -- inc l_string_map.forth end -- integers l_integer_map := l_user_information_reply_msg.integer_settings.map from l_integer_map.start until l_integer_map.after loop create l_int_ref l_int_ref.set_item (l_integer_map.item_for_iteration.value.to_integer_32) Result.force (l_int_ref, l_integer_map.key_for_iteration.value) -- increment l_integer_map.forth end -- doubles l_double_map := l_user_information_reply_msg.double_settings.map from l_double_map.start until l_double_map.after loop create l_double_ref l_double_ref.set_item (l_double_map.item_for_iteration.value) Result.force (l_double_ref, l_double_map.key_for_iteration.value) -- increment l_double_map.forth end end end end user_set_information (a_session: STRING; a_informations: ARRAY [ANY]): BOOLEAN_REF -- Set new information for user with session a_session. local l_msg: O_USER_SET_INFORMATION_MESSAGE l_informations: DS_ARRAYED_LIST[O_USER_INFORMATION_MESSAGE] l_information: DS_HASH_TABLE [ANY, STRING] l_information_type: STRING l_information_value: STRING i: INTEGER do -- argument validation check_anonymous_session (a_session) if not is_valid_session (a_session) then last_fault := err_invalid_session elseif a_informations = Void or else a_informations.is_empty then last_fault := err_invalid_information else last_fault := Void from i := 1 create l_informations.make (a_informations.count) until i > a_informations.count or last_fault /= Void loop l_information ?= a_informations.item (i) if l_information = Void then last_fault := err_invalid_information elseif not is_setting_type_ok (l_information) then last_fault := err_invalid_information else l_information_type := l_information.item ("information_type").out l_information_value := l_information.item ("information_value").out l_informations.force ( create {O_USER_INFORMATION_MESSAGE}.make ( l_information_type, l_information_value) , i) end i := i + 1 end if last_fault = Void then create l_msg.make (a_session, create {A_SEQUENCE_VALUE[O_USER_INFORMATION_MESSAGE]}.make (l_informations)) send_and_wait_for_reply (l_msg) if is_ok then create Result Result.set_item (True) end end end end user_set_icon (a_session: STRING; an_icon: STRING): BOOLEAN_REF -- Set new icon of user with session a_session. local l_msg: O_USER_SET_ICON_MESSAGE do -- argument validation check_anonymous_session (a_session) if not is_valid_session (a_session) then last_fault := err_invalid_session elseif not is_valid_file_name (an_icon) then last_fault := err_invalid_icon else -- generate and send message create l_msg.make (create {A_STRING_VALUE}.make (a_session), create {A_STRING_VALUE}.make (an_icon)) send_and_wait_for_reply (l_msg) if is_ok then create Result Result.set_item (True) end end end user_reset_icon (a_session: STRING): BOOLEAN_REF -- Reset icon of user with session a_session. local l_msg: O_USER_RESET_ICON_MESSAGE do -- argument validation check_anonymous_session (a_session) if not is_valid_session (a_session) then last_fault := err_invalid_session else -- generate and send message create l_msg.make (create {A_STRING_VALUE}.make (a_session)) send_and_wait_for_reply (l_msg) if is_ok then create Result Result.set_item (True) end end end user_login_key (a_user_key, a_app_key: STRING): STRING -- Login a user with a_user_key and a_app_key, return the session token on success. local l_msg: O_USER_LOGIN_KEY_MESSAGE l_session_msg: A_SESSION_MESSAGE do Result := "" -- argument validiation if not is_valid_key (a_user_key) then last_fault := err_invalid_user_key elseif not is_valid_key (a_app_key) then last_fault := err_invalid_app_key else -- generate and send message create l_msg.make (create {A_STRING_VALUE}.make (a_user_key), create {A_STRING_VALUE}.make (a_app_key)) send_and_wait_for_reply (l_msg) if is_ok then l_session_msg ?= last_reply check session_message: l_session_msg /= Void end Result := l_session_msg.session.value end end end user_add_bookmark (a_session: STRING; a_project: INTEGER_REF): BOOLEAN_REF -- Add bookmark to a_project local l_msg: O_USER_ADD_BOOKMARK_MESSAGE do -- argument validiation check_anonymous_session (a_session) if not is_valid_session (a_session) then last_fault := err_invalid_session elseif a_project <= 0 then last_fault := err_invalid_project else -- generate and send message create l_msg.make (create {A_STRING_VALUE}.make (a_session), create {A_INTEGER_VALUE}.make (a_project.item)) send_and_wait_for_reply (l_msg) if is_ok then create Result Result.set_item (True) end end end user_remove_bookmark (a_session: STRING; a_project: INTEGER_REF): BOOLEAN_REF -- Remove bookmark to a_project local l_msg: O_USER_REMOVE_BOOKMARK_MESSAGE do -- argument validiation check_anonymous_session (a_session) if not is_valid_session (a_session) then last_fault := err_invalid_session elseif a_project <= 0 then last_fault := err_invalid_project else -- generate and send message create l_msg.make (create {A_STRING_VALUE}.make (a_session), create {A_INTEGER_VALUE}.make (a_project.item)) send_and_wait_for_reply (l_msg) if is_ok then create Result Result.set_item (True) end end end user_list_bookmark (a_session: STRING; a_username: STRING): ARRAY [DS_HASH_TABLE [ANY, STRING]] -- List bookmarks of user a_username. local l_msg: O_USER_LIST_BOOKMARK_MESSAGE l_reply: O_USER_LIST_BOOKMARK_REPLY_MESSAGE l_project_map: DS_HASH_TABLE[A_STRING_VALUE, A_STRING_VALUE] l_project: DS_HASH_TABLE [ANY, STRING] i: INTEGER l_project_id_ref: INTEGER_REF do -- argument validiation check_anonymous_session (a_session) if not is_valid_session (a_session) then last_fault := err_invalid_session elseif a_username = Void or else a_username.is_empty then last_fault := err_invalid_user else create l_msg.make (create {A_STRING_VALUE}.make (a_session), create {A_STRING_VALUE}.make (a_username)) send_and_wait_for_reply (l_msg) if is_ok then l_reply ?= last_reply check bookmark_list_reply_message: l_reply /= Void end l_project_map := l_reply.project_list.map create Result.make (0, l_project_map.count-1) from l_project_map.start i := 0 until l_project_map.after loop create l_project.make (2) l_project.force (l_project_map.item_for_iteration.value, "name") create l_project_id_ref l_project_id_ref.set_item (l_project_map.key_for_iteration.value.to_integer) l_project.force (l_project_id_ref, "project_id") Result.force (l_project, i) -- Increment i := i + 1 l_project_map.forth end end end end user_set_workitem_subscription (a_session: STRING; a_project: INTEGER_REF; a_settings: ARRAY [ANY]): BOOLEAN_REF -- Set workitem subscription for `a_project'. local l_msg: O_USER_SET_WORKITEM_SUBSCRIPTION_MESSAGE -- l_settings: A_SEQUENCE_VALUE[O_USER_WORKITEM_SETTING_MESSAGE] l_settings_list: DS_ARRAYED_LIST[O_USER_WORKITEM_SETTING_MESSAGE] i: INTEGER l_workitem_type: INTEGER l_subscription_type: INTEGER l_is_enabled: BOOLEAN l_workitem_type_ref: INTEGER_REF l_subscription_type_ref: INTEGER_REF l_is_enabled_ref: BOOLEAN_REF l_setting: DS_HASH_TABLE [ANY, STRING] do -- argument validiation check_anonymous_session (a_session) if not is_valid_session (a_session) then last_fault := err_invalid_session elseif a_project <= 0 then last_fault := err_invalid_project elseif a_settings = Void or else a_settings.is_empty then last_fault := err_invalid_settings else -- FIXME structs should be validated -- generate and send message from i := 1 create l_settings_list.make (a_settings.count) until i > a_settings.count loop l_setting ?= a_settings.item (i) if l_setting = Void then last_fault := err_invalid_settings else l_workitem_type_ref ?= l_setting.item ("workitem_type") l_subscription_type_ref ?= l_setting.item ("subscription_type") l_is_enabled_ref ?= l_setting.item ("is_enabled") l_workitem_type := l_workitem_type_ref.item l_subscription_type := l_subscription_type_ref.item l_is_enabled := l_is_enabled_ref.item if l_workitem_type <= 0 then last_fault := err_invalid_workitem_type elseif l_subscription_type <= 0 then last_fault := err_invalid_subscription_type else l_settings_list.force( create {O_USER_WORKITEM_SETTING_MESSAGE}.make ( create {A_INTEGER_VALUE}.make (l_workitem_type), create {A_INTEGER_VALUE}.make (l_subscription_type), create {A_BOOLEAN_VALUE}.make (l_is_enabled)), i ) end end -- Increment i := i + 1 end if last_fault = Void then create l_msg.make ( create {A_STRING_VALUE}.make (a_session), create {A_INTEGER_VALUE}.make (a_project.item), create {A_SEQUENCE_VALUE[O_USER_WORKITEM_SETTING_MESSAGE]}.make (l_settings_list) ) send_and_wait_for_reply (l_msg) if is_ok then create Result Result.set_item (True) end end end end user_list_workitem_subscription (a_session: STRING; a_project: INTEGER_REF): ARRAY [DS_HASH_TABLE [ANY, STRING]] -- List workitem subscriptions for `a_project'. local l_msg: O_USER_LIST_WORKITEM_SUBSCRIPTION_MESSAGE l_reply: O_USER_WORKITEM_SUBSCRIPTIONS_MESSAGE l_subscription_list: DS_ARRAYED_LIST[O_USER_SUBSCRIPTION_SETTING_MESSAGE] l_subscription: DS_HASH_TABLE [ANY, STRING] i: INTEGER l_wi_type_ref: INTEGER_REF l_s_type_ref: INTEGER_REF do -- argument validiation check_anonymous_session (a_session) if not is_valid_session (a_session) then last_fault := err_invalid_session elseif a_project <= 0 then last_fault := err_invalid_project else create l_msg.make (create {A_STRING_VALUE}.make (a_session), create {A_INTEGER_VALUE}.make (a_project.item)) send_and_wait_for_reply (l_msg) if is_ok then l_reply ?= last_reply check reply_message: l_reply /= Void end l_subscription_list := l_reply.subscriptions.sequence create Result.make (0, l_subscription_list.count-1) from l_subscription_list.start i := 0 until l_subscription_list.after loop create l_subscription.make (2) create l_wi_type_ref l_wi_type_ref.set_item (l_subscription_list.item_for_iteration.workitem_type.value.to_integer) l_subscription.force (l_wi_type_ref, "workitem_type") create l_s_type_ref l_s_type_ref.set_item (l_subscription_list.item_for_iteration.subscription_type.value.to_integer) l_subscription.force (l_s_type_ref, "subscription_type") Result.force (l_subscription, i) -- Increment i := i + 1 l_subscription_list.forth end end end end user_reported_issues_count (a_session: STRING): INTEGER_REF -- Returns the total number of reported issues for the user. local l_msg: O_USER_REPORTED_ISSUES_COUNT_MESSAGE l_reply: O_USER_REPORTED_ISSUES_COUNT_REPLY_MESSAGE do -- argument validiation check_anonymous_session (a_session) if not is_valid_session (a_session) then last_fault := err_invalid_session else create l_msg.make (a_session) send_and_wait_for_reply (l_msg) if is_ok then l_reply ?= last_reply check reply_ok: l_reply /= Void end create Result Result.set_item (l_reply.issue_count) end end end user_list_reported_issues (a_session: STRING; a_start: INTEGER_REF; a_limit: INTEGER_REF; a_sort_column: STRING; a_sort_order: STRING): ARRAY [DS_HASH_TABLE [ANY, STRING]] -- List issues for a specific user `a_username' local l_msg: O_USER_LIST_REPORTED_ISSUES_MESSAGE l_issue_list_reply_msg: O_USER_LIST_REPORTED_ISSUES_REPLY_MESSAGE l_issue_list: DS_ARRAYED_LIST [O_USER_ISSUE_MESSAGE] l_issue_message: O_USER_ISSUE_MESSAGE l_issue: DS_HASH_TABLE [ANY, STRING] i: INTEGER l_issue_id_ref: INTEGER_REF l_creation_time_ref: INTEGER_REF l_deadline_ref: INTEGER_REF l_work_amount_ref: INTEGER_REF do -- argument validiation check_anonymous_session (a_session) if not is_valid_session (a_session) then last_fault := err_invalid_session elseif a_start < 0 then last_fault := err_invalid_index elseif a_limit <= 0 then last_fault := err_invalid_limit elseif a_sort_order = Void then last_fault := err_invalid_sort_order else create l_msg.make (a_session, a_start.item, a_limit.item, a_sort_column, a_sort_order) send_and_wait_for_reply (l_msg) if is_ok then l_issue_list_reply_msg ?= last_reply check issue_list_reply_message: l_issue_list_reply_msg /= Void end l_issue_list := l_issue_list_reply_msg.issue_list.sequence create Result.make (0, l_issue_list.count - 1) from l_issue_list.start i := 0 until l_issue_list.after loop l_issue_message := l_issue_list.item_for_iteration create l_issue.make (5) create l_issue_id_ref l_issue_id_ref.set_item (l_issue_message.project_issue_id) l_issue.force (l_issue_id_ref, "issue_id") l_issue.force (l_issue_message.title.value, "title") create l_deadline_ref l_deadline_ref.set_item (l_issue_message.deadline) l_issue.force (l_deadline_ref, "deadline") create l_work_amount_ref l_work_amount_ref.set_item (l_issue_message.work_amount) l_issue.force (l_work_amount_ref, "work_amount") l_issue.force (l_issue_message.project_name.value, "project_name") create l_creation_time_ref l_creation_time_ref.set_item (l_issue_message.last_updated) l_issue.force (l_creation_time_ref, "last_updated") l_issue.force (l_issue_message.tags.value, "tags") l_issue.force (l_issue_message.status.value, "status") l_issue.force (l_issue_message.assigned.value, "assigned") Result.force (l_issue, i) -- Increment l_issue_list.forth i := i + 1 end end end end user_request_friendship (a_session: STRING; a_requestee: STRING): BOOLEAN_REF -- User with session `a_session' requests friendship with `a_requestee'. local l_msg: O_USER_REQUEST_FRIENDSHIP_MESSAGE do -- argument validation check_anonymous_session (a_session) if not is_valid_session(a_session) then last_fault := err_invalid_session elseif a_requestee = Void or else a_requestee.is_empty then last_fault := err_invalid_user else -- generate and send message create l_msg.make (create {A_STRING_VALUE}.make (a_session), create {A_STRING_VALUE}.make (a_requestee)) send_and_wait_for_reply (l_msg) if is_ok then create Result Result.set_item (True) end end end user_process_friendship_request (a_session: STRING; a_requester: STRING; an_accept: BOOLEAN_REF): BOOLEAN_REF -- User with session `a_session' processes friendship request from `a_requester'. -- Accept: `an_accept' = True, Reject: `an_accept' = False local l_msg: O_USER_PROCESS_FRIENDSHIP_REQUEST_MESSAGE do -- argument validation check_anonymous_session (a_session) if not is_valid_session(a_session) then last_fault := err_invalid_session elseif a_requester = Void or else a_requester.is_empty then last_fault := err_invalid_user else -- generate and send message create l_msg.make (create {A_STRING_VALUE}.make (a_session), create {A_STRING_VALUE}.make (a_requester), create {A_BOOLEAN_VALUE}.make (an_accept)) send_and_wait_for_reply (l_msg) if is_ok then create Result Result.set_item (True) end end end user_remove_friendship (a_session: STRING; a_friend: STRING): BOOLEAN_REF -- User with session `a_session' removes friendship with `a_friend'. local l_msg: O_USER_REMOVE_FRIENDSHIP_MESSAGE do -- argument validation check_anonymous_session (a_session) if not is_valid_session(a_session) then last_fault := err_invalid_session elseif a_friend = Void or else a_friend.is_empty then last_fault := err_invalid_user else -- generate and send message create l_msg.make (create {A_STRING_VALUE}.make (a_session), create {A_STRING_VALUE}.make (a_friend)) send_and_wait_for_reply (l_msg) if is_ok then create Result Result.set_item (True) end end end user_list_friends (a_session: STRING; a_username: STRING) : ARRAY [DS_HASH_TABLE [ANY, STRING]] -- List friends of user `a_username'. local l_msg: O_USER_LIST_FRIENDS_MESSAGE l_reply: O_USER_LIST_FRIENDS_REPLY_MESSAGE l_friend_map: DS_HASH_TABLE[O_USER_FRIEND_MESSAGE, A_STRING_VALUE] l_friend: DS_HASH_TABLE [ANY, STRING] i: INTEGER do -- argument validation check_anonymous_session (a_session) if not is_valid_session (a_session) then last_fault := err_invalid_session elseif a_username = Void or else a_username.is_empty then last_fault := err_invalid_user else -- generate and send message create l_msg.make (create {A_STRING_VALUE}.make (a_session), create {A_STRING_VALUE}.make (a_username)) send_and_wait_for_reply (l_msg) if is_ok then l_reply ?= last_reply check valid_reply_message: l_reply /= Void end l_friend_map := l_reply.friend_list.map create Result.make (0, l_friend_map.count - 1) from l_friend_map.start i := 0 until l_friend_map.after loop create l_friend.make (2) l_friend.force (l_friend_map.item_for_iteration.name.value, "name") l_friend.force (l_friend_map.item_for_iteration.icon.value, "icon") l_friend.force (l_friend_map.item_for_iteration.real_name.value, "real_name") Result.force (l_friend, i) -- Increment i := i + 1 l_friend_map.forth end end end end user_send_message (a_session, a_username, a_subject, a_message: STRING) : BOOLEAN_REF -- Send a message to `a_username' with `a_subject' and `a_message'. local l_msg: O_USER_SEND_MESSAGE_MESSAGE do -- argument validation check_anonymous_session (a_session) if not is_valid_session (a_session) then last_fault := err_invalid_session elseif a_username = Void or else a_username.is_empty then last_fault := err_invalid_user elseif a_subject = Void or else a_subject.is_empty then last_fault := err_invalid_subject elseif a_message = Void or else a_message.is_empty then last_fault := err_invalid_message else -- generate and send message create l_msg.make (create {A_STRING_VALUE}.make (a_session), create {A_STRING_VALUE}.make (a_username), create {A_STRING_VALUE}.make (a_subject), create {A_STRING_VALUE}.make (a_message)) send_and_wait_for_reply (l_msg) if is_ok then create Result Result.set_item (True) end end end user_disable_account (a_session: STRING; a_user_name: STRING) : BOOLEAN_REF -- Disable account of user with `a_session'. local l_msg: O_USER_DISABLE_ACCOUNT_MESSAGE do -- argument validation check_anonymous_session (a_session) if not is_valid_session (a_session) then last_fault := err_invalid_session elseif a_user_name = Void or else a_user_name.is_empty then last_fault := err_invalid_name else -- generate and send message create l_msg.make (a_session, a_user_name) send_and_wait_for_reply (l_msg) if is_ok then create Result Result.set_item (True) end end end user_list_communities (a_session: STRING; a_username: STRING): ARRAY [DS_HASH_TABLE [ANY, STRING]] -- List communities of user a_username. local l_msg: O_USER_LIST_COMMUNITIES_MESSAGE l_reply: O_COMMUNITY_LIST_REPLY_MESSAGE l_communitiy_list: DS_ARRAYED_LIST [A_STRING_VALUE] l_community: DS_HASH_TABLE [ANY, STRING] i: INTEGER do -- argument validiation check_anonymous_session (a_session) if not is_valid_session (a_session) then last_fault := err_invalid_session elseif a_username = Void or else a_username.is_empty then last_fault := err_invalid_user else create l_msg.make (create {A_STRING_VALUE}.make (a_session), create {A_STRING_VALUE}.make (a_username)) send_and_wait_for_reply (l_msg) if is_ok then l_reply ?= last_reply check valid_reply: l_reply /= Void end l_communitiy_list := l_reply.community_list.sequence create Result.make (0, l_communitiy_list.count - 1) from l_communitiy_list.start i := 0 until l_communitiy_list.after loop create l_community.make (1) l_community.force (l_communitiy_list.item_for_iteration.value, "name") Result.force (l_community, i) i := i + 1 l_communitiy_list.forth end end end end feature -- Creation new_tuple (a_name: STRING): TUPLE -- Tuple of default-valued arguments to pass to call `a_name'. do if a_name.is_equal (user_my_name_name) then create {TUPLE [STRING]}Result elseif a_name.is_equal (user_my_password_name) then create {TUPLE [STRING]}Result elseif a_name.is_equal (user_my_email_name) then create {TUPLE [STRING]}Result elseif a_name.is_equal (user_profile_visible_name) then create {TUPLE [STRING]}Result elseif a_name.is_equal (user_change_profile_visible_name) then create {TUPLE [STRING, INTEGER_REF]}Result elseif a_name.is_equal (user_retrieve_information_name) then create {TUPLE [STRING, STRING]}Result elseif a_name.is_equal (user_set_information_name) then create {TUPLE [STRING, ARRAY [ANY]]}Result elseif a_name.is_equal (user_set_icon_name) then create {TUPLE [STRING, STRING]}Result elseif a_name.is_equal (user_reset_icon_name) then create {TUPLE [STRING]}Result elseif a_name.is_equal (user_login_key_name) then create {TUPLE [STRING, STRING]}Result elseif a_name.is_equal (user_add_bookmark_name) then create {TUPLE [STRING, INTEGER_REF]}Result elseif a_name.is_equal (user_remove_bookmark_name) then create {TUPLE [STRING, INTEGER_REF]}Result elseif a_name.is_equal (user_list_bookmark_name) then create {TUPLE [STRING, STRING]}Result elseif a_name.is_equal (user_set_workitem_subscription_name) then create {TUPLE [STRING, INTEGER_REF, ARRAY [ANY]]}Result elseif a_name.is_equal (user_list_workitem_subscription_name) then create {TUPLE [STRING, INTEGER_REF]}Result elseif a_name.is_equal (user_reported_issues_count_name) then create {TUPLE [STRING]}Result elseif a_name.is_equal (user_list_reported_issues_name) then create {TUPLE [STRING, INTEGER_REF, INTEGER_REF, STRING, STRING]}Result elseif a_name.is_equal (user_request_friendship_name) then create {TUPLE [STRING, STRING]}Result elseif a_name.is_equal (user_process_friendship_request_name) then create {TUPLE [STRING, STRING, BOOLEAN_REF]}Result elseif a_name.is_equal (user_remove_friendship_name) then create {TUPLE [STRING, STRING]}Result elseif a_name.is_equal (user_list_friends_name) then create {TUPLE [STRING, STRING]}Result elseif a_name.is_equal (user_send_message_name) then create {TUPLE [STRING, STRING, STRING, STRING]}Result elseif a_name.is_equal (user_disable_account_name) then create {TUPLE [STRING, STRING]}Result elseif a_name.is_equal (user_list_communities_name) then create {TUPLE [STRING, STRING]}Result end end feature -- Initialisation self_register -- Register all actions for this service do register_with_help (agent user_my_name, user_my_name_name, "Your user name.") register_with_help (agent user_my_password, user_my_password_name, "Your password.") register_with_help (agent user_my_email, user_my_email_name, "Your email address.") register_with_help (agent user_profile_visible, user_profile_visible_name, "Your profile visibility.") register_with_help (agent user_change_profile_visible, user_change_profile_visible_name, "Set profile visibility.") register_with_help (agent user_retrieve_information, user_retrieve_information_name, "Retrieve user information.") register_with_help (agent user_set_information, user_set_information_name, "Set user information.") register_with_help (agent user_set_icon, user_set_icon_name, "Set user icon.") register_with_help (agent user_reset_icon, user_reset_icon_name, "Reset user icon to default image.") register_with_help (agent user_login_key, user_login_key_name, "Login with user_key and application_key, receive a session.") register_with_help (agent user_add_bookmark, user_add_bookmark_name, "Add bookmark to project") register_with_help (agent user_remove_bookmark, user_remove_bookmark_name, "Remove bookmark to project") register_with_help (agent user_list_bookmark, user_list_bookmark_name, "List bookmarks for a user") register_with_help (agent user_set_workitem_subscription, user_set_workitem_subscription_name, "Set workitem type subscriptions") register_with_help (agent user_list_workitem_subscription, user_list_workitem_subscription_name, "List workitem type subscriptions") register_with_help (agent user_reported_issues_count, user_reported_issues_count_name, "Retrieve the total number of issues reported by the user.") register_with_help (agent user_list_reported_issues, user_list_reported_issues_name, "List reported issues for a user.") register_with_help (agent user_request_friendship, user_request_friendship_name, "Request friendship between two users.") register_with_help (agent user_process_friendship_request, user_process_friendship_request_name, "Process a friendship request.") register_with_help (agent user_remove_friendship, user_remove_friendship_name, "Removes friendship with a user.") register_with_help (agent user_list_friends, user_list_friends_name, "List friends for a user") register_with_help (agent user_send_message, user_send_message_name, "Send a message to a user") register_with_help (agent user_disable_account, user_disable_account_name, "Disable a user account") register_with_help (agent user_list_communities, user_list_communities_name, "List communities for a user.") end feature {NONE} -- Utilities valid_user_settings: DS_HASH_TABLE[STRING, STRING] local l_msg: O_USER_RETRIEVE_VALID_SETTING_NAMES_MESSAGE l_reply: O_USER_RETRIEVE_VALID_SETTING_NAMES_REPLY_MESSAGE l_names: DS_HASH_TABLE [A_STRING_VALUE, A_STRING_VALUE] once create l_msg.make send_and_wait_for_reply (l_msg) create Result.make_default if is_ok then l_reply ?= last_reply check valid_reply: l_reply /= Void end l_names := l_reply.names.map from l_names.start until l_names.after loop Result.force (l_names.item_for_iteration, l_names.key_for_iteration) -- increment l_names.forth end end end is_setting_type_ok (a_information: DS_HASH_TABLE [ANY, STRING]): BOOLEAN -- Utility function for (type-) checking a desired user-information value received from the frontend. require exists: a_information /= Void local l_information_type: STRING l_information_value: STRING l_int: INTEGER_REF l_double: DOUBLE_REF l_string: STRING l_type_value: STRING do l_information_type := a_information.item ("information_type").out l_information_value := a_information.item ("information_value").out if not valid_user_settings.has (l_information_type) then Result := False else l_type_value := valid_user_settings.item (l_information_type) -- Check type if valid_user_settings.item (l_information_type).is_equal ("integer") then l_int ?= l_information_value.to_integer Result := (l_int /= Void) elseif valid_user_settings.item (l_information_type).is_equal ("double") then l_double ?= l_information_value.to_double Result := (l_double /= Void) elseif valid_user_settings.item (l_information_type).is_equal ("string") then l_string := l_information_value Result := (l_string /= Void) else -- invalid, unsupported type Result := False end end end feature {NONE} -- Implementation user_my_name_name: STRING = "my_name" user_login_key_name: STRING = "login_key" user_my_password_name: STRING = "my_password" user_my_email_name: STRING = "my_email" user_profile_visible_name: STRING = "profile_visible" user_change_profile_visible_name: STRING = "change_profile_visible" user_retrieve_information_name: STRING = "retrieve_information" user_set_information_name: STRING = "set_information" user_set_icon_name: STRING = "set_icon" user_reset_icon_name: STRING = "reset_icon" user_add_bookmark_name: STRING = "add_bookmark" user_remove_bookmark_name: STRING = "remove_bookmark" user_list_bookmark_name: STRING = "list_bookmark" user_set_workitem_subscription_name: STRING = "set_workitem_subscription" user_list_workitem_subscription_name: STRING = "list_workitem_subscription" user_reported_issues_count_name: STRING = "reported_issues_count" user_list_reported_issues_name: STRING = "list_reported_issues" user_request_friendship_name: STRING = "request_friendship" user_process_friendship_request_name: STRING = "process_friendship_request" user_remove_friendship_name: STRING = "remove_friendship" user_list_friends_name: STRING = "list_friends" user_send_message_name: STRING = "send_message" user_disable_account_name: STRING = "disable_account" user_list_communities_name: STRING = "list_communities" end