00001
00032 #include "llviewerprecompiledheaders.h"
00033
00034 #include "llconfirmationmanager.h"
00035
00036 #include "lluictrlfactory.h"
00037
00038
00039 #include "llviewerwindow.h"
00040 #include "lllineeditor.h"
00041 #include "llstring.h"
00042
00043 LLConfirmationManager::ListenerBase::~ListenerBase()
00044 {
00045 }
00046
00047
00048 static void onConfirmAlert(S32 option, void* data)
00049 {
00050 LLConfirmationManager::ListenerBase* listener
00051 = (LLConfirmationManager::ListenerBase*)data;
00052
00053 if (option == 0)
00054 {
00055 listener->confirmed("");
00056 }
00057
00058 delete listener;
00059 }
00060
00061 static void onConfirmAlertPassword(
00062 S32 option, const LLString& text, void* data)
00063 {
00064 LLConfirmationManager::ListenerBase* listener
00065 = (LLConfirmationManager::ListenerBase*)data;
00066
00067 if (option == 0)
00068 {
00069 listener->confirmed(text);
00070 }
00071
00072 delete listener;
00073 }
00074
00075
00076 void LLConfirmationManager::confirm(Type type,
00077 const std::string& action,
00078 ListenerBase* listener)
00079 {
00080 LLString::format_map_t args;
00081 args["[ACTION]"] = action;
00082
00083 switch (type)
00084 {
00085 case TYPE_CLICK:
00086 gViewerWindow->alertXml("ConfirmPurchase", args,
00087 onConfirmAlert, listener);
00088 break;
00089
00090 case TYPE_PASSWORD:
00091 gViewerWindow->alertXmlEditText("ConfirmPurchasePassword", args,
00092 NULL, NULL,
00093 onConfirmAlertPassword, listener,
00094 LLString::format_map_t(),
00095 TRUE);
00096 break;
00097 case TYPE_NONE:
00098 default:
00099 listener->confirmed("");
00100 break;
00101 }
00102 }
00103
00104
00105 void LLConfirmationManager::confirm(
00106 const std::string& type,
00107 const std::string& action,
00108 ListenerBase* listener)
00109 {
00110 Type decodedType = TYPE_NONE;
00111
00112 if (type == "click")
00113 {
00114 decodedType = TYPE_CLICK;
00115 }
00116 else if (type == "password")
00117 {
00118 decodedType = TYPE_PASSWORD;
00119 }
00120
00121 confirm(decodedType, action, listener);
00122 }
00123