diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/llfloaterpostcard.cpp | 148 |
1 files changed, 100 insertions, 48 deletions
diff --git a/linden/indra/newview/llfloaterpostcard.cpp b/linden/indra/newview/llfloaterpostcard.cpp index 2c80300..82bab03 100644 --- a/linden/indra/newview/llfloaterpostcard.cpp +++ b/linden/indra/newview/llfloaterpostcard.cpp | |||
@@ -76,12 +76,12 @@ LLFloaterPostcard::LLFloaterPostcard(LLImageJPEG* jpeg, LLImageGL *img, const LL | |||
76 | mJPEGImage(jpeg), | 76 | mJPEGImage(jpeg), |
77 | mViewerImage(img), | 77 | mViewerImage(img), |
78 | mImageScale(img_scale), | 78 | mImageScale(img_scale), |
79 | mPosTakenGlobal(pos_taken_global) | 79 | mPosTakenGlobal(pos_taken_global), |
80 | mHasFirstMsgFocus(false) | ||
80 | { | 81 | { |
81 | init(); | 82 | init(); |
82 | } | 83 | } |
83 | 84 | ||
84 | |||
85 | void LLFloaterPostcard::init() | 85 | void LLFloaterPostcard::init() |
86 | { | 86 | { |
87 | // pick up the user's up-to-date email address | 87 | // pick up the user's up-to-date email address |
@@ -128,25 +128,24 @@ BOOL LLFloaterPostcard::postBuild() | |||
128 | gAgent.buildFullname(name_string); | 128 | gAgent.buildFullname(name_string); |
129 | 129 | ||
130 | childSetValue("name_form", LLSD(name_string)); | 130 | childSetValue("name_form", LLSD(name_string)); |
131 | |||
132 | // XUI:translate | ||
133 | LLString msg("Postcard from "); | ||
134 | msg += gSecondLife; | ||
135 | childSetValue("subject_form", LLSD(msg)); | ||
136 | 131 | ||
137 | LLTextEditor *MsgField = LLUICtrlFactory::getTextEditorByName(this, "msg_form"); | 132 | LLTextEditor *MsgField = LLUICtrlFactory::getTextEditorByName(this, "msg_form"); |
138 | if (MsgField) | 133 | if (MsgField) |
139 | { | 134 | { |
140 | MsgField->setText("Check this out!"); | ||
141 | MsgField->setWordWrap(TRUE); | 135 | MsgField->setWordWrap(TRUE); |
142 | } | ||
143 | 136 | ||
144 | childSetFocus("to_form", TRUE); | 137 | // For the first time a user focusess to .the msg box, all text will be selected. |
138 | MsgField->setFocusChangedCallback(onMsgFormFocusRecieved); | ||
139 | MsgField->setCallbackUserData(this); | ||
140 | } | ||
145 | 141 | ||
142 | childSetFocus("to_form", TRUE); | ||
143 | |||
146 | return TRUE; | 144 | return TRUE; |
147 | } | 145 | } |
148 | 146 | ||
149 | 147 | ||
148 | |||
150 | // static | 149 | // static |
151 | LLFloaterPostcard* LLFloaterPostcard::showFromSnapshot(LLImageJPEG *jpeg, LLImageGL *img, const LLVector2 &image_scale, const LLVector3d& pos_taken_global) | 150 | LLFloaterPostcard* LLFloaterPostcard::showFromSnapshot(LLImageJPEG *jpeg, LLImageGL *img, const LLVector2 &image_scale, const LLVector3d& pos_taken_global) |
152 | { | 151 | { |
@@ -267,46 +266,16 @@ void LLFloaterPostcard::onClickSend(void* data) | |||
267 | return; | 266 | return; |
268 | } | 267 | } |
269 | 268 | ||
270 | if (self->mJPEGImage.notNull()) | 269 | LLString subject(self->childGetValue("subject_form").asString().c_str()); |
270 | if(subject.empty() || !self->mHasFirstMsgFocus) | ||
271 | { | 271 | { |
272 | self->mTransactionID.generate(); | 272 | gViewerWindow->alertXml("PromptMissingSubjMsg", missingSubjMsgAlertCallback, self); |
273 | self->mAssetID = self->mTransactionID.makeAssetID(gAgent.getSecureSessionID()); | 273 | return; |
274 | LLVFile::writeFile(self->mJPEGImage->getData(), self->mJPEGImage->getDataSize(), gVFS, self->mAssetID, LLAssetType::AT_IMAGE_JPEG); | 274 | } |
275 | |||
276 | // upload the image | ||
277 | std::string url = gAgent.getRegion()->getCapability("SendPostcard"); | ||
278 | if(!url.empty()) | ||
279 | { | ||
280 | llinfos << "Send Postcard via capability" << llendl; | ||
281 | LLSD body = LLSD::emptyMap(); | ||
282 | // the capability already encodes: agent ID, region ID | ||
283 | body["pos-global"] = self->mPosTakenGlobal.getValue(); | ||
284 | body["to"] = self->childGetValue("to_form").asString(); | ||
285 | body["from"] = self->childGetValue("from_form").asString(); | ||
286 | body["name"] = self->childGetValue("name_form").asString(); | ||
287 | body["subject"] = self->childGetValue("subject_form").asString(); | ||
288 | body["msg"] = self->childGetValue("msg_form").asString(); | ||
289 | body["allow-publish"] = self->childGetValue("allow_publish_check").asBoolean(); | ||
290 | body["mature-publish"] = self->childGetValue("mature_check").asBoolean(); | ||
291 | LLHTTPClient::post(url, body, new LLSendPostcardResponder(body, self->mAssetID, LLAssetType::AT_IMAGE_JPEG)); | ||
292 | } | ||
293 | else | ||
294 | { | ||
295 | gAssetStorage->storeAssetData(self->mTransactionID, LLAssetType::AT_IMAGE_JPEG, &uploadCallback, (void *)self, FALSE); | ||
296 | } | ||
297 | |||
298 | LLUploadDialog::modalUploadDialog("Uploading...\n\nPostcard"); | ||
299 | |||
300 | // don't destroy the window until the upload is done | ||
301 | // this way we keep the information in the form | ||
302 | self->setVisible(FALSE); | ||
303 | 275 | ||
304 | // also remove any dependency on another floater | 276 | if (self->mJPEGImage.notNull()) |
305 | // so that we can be sure to outlive it while we | 277 | { |
306 | // need to. | 278 | self->sendPostcard(); |
307 | LLFloater* dependee = self->getDependee(); | ||
308 | if (dependee) | ||
309 | dependee->removeDependentFloater(self); | ||
310 | } | 279 | } |
311 | else | 280 | else |
312 | { | 281 | { |
@@ -375,3 +344,86 @@ void LLFloaterPostcard::updateUserInfo(const char *email) | |||
375 | } | 344 | } |
376 | } | 345 | } |
377 | } | 346 | } |
347 | |||
348 | void LLFloaterPostcard::onMsgFormFocusRecieved(LLUICtrl* receiver, void* data) | ||
349 | { | ||
350 | LLFloaterPostcard* self = (LLFloaterPostcard *)data; | ||
351 | if(self) | ||
352 | { | ||
353 | LLTextEditor* msgForm = LLUICtrlFactory::getTextEditorByName(self, "msg_form"); | ||
354 | if(msgForm && msgForm == receiver && msgForm->hasFocus() && !(self->mHasFirstMsgFocus)) | ||
355 | { | ||
356 | self->mHasFirstMsgFocus = true; | ||
357 | msgForm->setText(LLString("")); | ||
358 | } | ||
359 | } | ||
360 | } | ||
361 | |||
362 | void LLFloaterPostcard::missingSubjMsgAlertCallback(S32 option, void* data) | ||
363 | { | ||
364 | if(data) | ||
365 | { | ||
366 | LLFloaterPostcard* self = static_cast<LLFloaterPostcard*>(data); | ||
367 | if(0 == option) | ||
368 | { | ||
369 | // User clicked OK | ||
370 | if((self->childGetValue("subject_form").asString()).empty()) | ||
371 | { | ||
372 | // Stuff the subject back into the form. | ||
373 | self->childSetValue("subject_form", self->childGetText("default_subject")); | ||
374 | } | ||
375 | |||
376 | if(!self->mHasFirstMsgFocus) | ||
377 | { | ||
378 | // The user never switched focus to the messagee window. | ||
379 | // Using the default string. | ||
380 | // XUI: translate | ||
381 | self->childSetValue("msg_form", self->childGetText("default_message")); | ||
382 | } | ||
383 | |||
384 | self->sendPostcard(); | ||
385 | } | ||
386 | } | ||
387 | } | ||
388 | |||
389 | void LLFloaterPostcard::sendPostcard() | ||
390 | { | ||
391 | mTransactionID.generate(); | ||
392 | mAssetID = mTransactionID.makeAssetID(gAgent.getSecureSessionID()); | ||
393 | LLVFile::writeFile(mJPEGImage->getData(), mJPEGImage->getDataSize(), gVFS, mAssetID, LLAssetType::AT_IMAGE_JPEG); | ||
394 | |||
395 | // upload the image | ||
396 | std::string url = gAgent.getRegion()->getCapability("SendPostcard"); | ||
397 | if(!url.empty()) | ||
398 | { | ||
399 | llinfos << "Send Postcard via capability" << llendl; | ||
400 | LLSD body = LLSD::emptyMap(); | ||
401 | // the capability already encodes: agent ID, region ID | ||
402 | body["pos-global"] = mPosTakenGlobal.getValue(); | ||
403 | body["to"] = childGetValue("to_form").asString(); | ||
404 | body["from"] = childGetValue("from_form").asString(); | ||
405 | body["name"] = childGetValue("name_form").asString(); | ||
406 | body["subject"] = childGetValue("subject_form").asString(); | ||
407 | body["msg"] = childGetValue("msg_form").asString(); | ||
408 | body["allow-publish"] = childGetValue("allow_publish_check").asBoolean(); | ||
409 | body["mature-publish"] = childGetValue("mature_check").asBoolean(); | ||
410 | LLHTTPClient::post(url, body, new LLSendPostcardResponder(body, mAssetID, LLAssetType::AT_IMAGE_JPEG)); | ||
411 | } | ||
412 | else | ||
413 | { | ||
414 | gAssetStorage->storeAssetData(mTransactionID, LLAssetType::AT_IMAGE_JPEG, &uploadCallback, (void *)this, FALSE); | ||
415 | } | ||
416 | |||
417 | LLUploadDialog::modalUploadDialog("Uploading...\n\nPostcard"); | ||
418 | |||
419 | // don't destroy the window until the upload is done | ||
420 | // this way we keep the information in the form | ||
421 | setVisible(FALSE); | ||
422 | |||
423 | // also remove any dependency on another floater | ||
424 | // so that we can be sure to outlive it while we | ||
425 | // need to. | ||
426 | LLFloater* dependee = getDependee(); | ||
427 | if (dependee) | ||
428 | dependee->removeDependentFloater(this); | ||
429 | } | ||