Skip to content

Commit

Permalink
Readding these methods were unnecessary actually. Forgot I had alread…
Browse files Browse the repository at this point in the history
…y moved them to LLProfileImagePicker.
  • Loading branch information
cinderblocks committed Dec 24, 2024
1 parent 741b751 commit bc9b6a3
Showing 1 changed file with 0 additions and 151 deletions.
151 changes: 0 additions & 151 deletions indra/newview/llpanelprofile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,157 +102,6 @@ static const std::string PANEL_PROFILE_VIEW = "panel_profile_view";
static const std::string PROFILE_PROPERTIES_CAP = "AgentProfile";
static const std::string PROFILE_IMAGE_UPLOAD_CAP = "UploadAgentProfileImage";


//////////////////////////////////////////////////////////////////////////

LLUUID post_profile_image(std::string cap_url, const LLSD &first_data, std::string path_to_image, LLHandle<LLPanel> *handle)
{
LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t
httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("post_profile_image_coro", httpPolicy));
LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest);
LLCore::HttpHeaders::ptr_t httpHeaders;

LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions);
httpOpts->setFollowRedirects(true);

LLSD result = httpAdapter->postAndSuspend(httpRequest, cap_url, first_data, httpOpts, httpHeaders);

LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);

if (!status)
{
// todo: notification?
LL_WARNS("AvatarProperties") << "Failed to get uploader cap " << status.toString() << LL_ENDL;
return LLUUID::null;
}
if (!result.has("uploader"))
{
// todo: notification?
LL_WARNS("AvatarProperties") << "Failed to get uploader cap, response contains no data." << LL_ENDL;
return LLUUID::null;
}
std::string uploader_cap = result["uploader"].asString();
if (uploader_cap.empty())
{
LL_WARNS("AvatarProperties") << "Failed to get uploader cap, cap invalid." << LL_ENDL;
return LLUUID::null;
}

// Upload the image
LLCore::HttpRequest::ptr_t uploaderhttpRequest(new LLCore::HttpRequest);
LLCore::HttpHeaders::ptr_t uploaderhttpHeaders(new LLCore::HttpHeaders);
LLCore::HttpOptions::ptr_t uploaderhttpOpts(new LLCore::HttpOptions);
S64 length;

{
llifstream instream(path_to_image.c_str(), std::iostream::binary | std::iostream::ate);
if (!instream.is_open())
{
LL_WARNS("AvatarProperties") << "Failed to open file " << path_to_image << LL_ENDL;
return LLUUID::null;
}
length = instream.tellg();
}

uploaderhttpHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, "application/jp2"); // optional
uploaderhttpHeaders->append(HTTP_OUT_HEADER_CONTENT_LENGTH, llformat("%d", length)); // required!
uploaderhttpOpts->setFollowRedirects(true);

result = httpAdapter->postFileAndSuspend(uploaderhttpRequest, uploader_cap, path_to_image, uploaderhttpOpts, uploaderhttpHeaders);

httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);

LL_DEBUGS("AvatarProperties") << result << LL_ENDL;

if (!status)
{
LL_WARNS("AvatarProperties") << "Failed to upload image " << status.toString() << LL_ENDL;
return LLUUID::null;
}

if (result["state"].asString() != "complete")
{
if (result.has("message"))
{
LL_WARNS("AvatarProperties") << "Failed to upload image, state " << result["state"] << " message: " << result["message"] << LL_ENDL;
}
else
{
LL_WARNS("AvatarProperties") << "Failed to upload image " << result << LL_ENDL;
}
return LLUUID::null;
}

return result["new_asset"].asUUID();
}

void post_profile_image_coro(std::string cap_url, EProfileImageType type, std::string path_to_image, LLHandle<LLPanel> *handle)
{
LLSD data;
switch (type)
{
case PROFILE_IMAGE_SL:
data["profile-image-asset"] = "sl_image_id";
break;
case PROFILE_IMAGE_FL:
data["profile-image-asset"] = "fl_image_id";
break;
}

LLUUID result = post_profile_image(cap_url, data, path_to_image, handle);

// reset loading indicator
if (!handle->isDead())
{
switch (type)
{
case PROFILE_IMAGE_SL:
{
LLPanelProfileSecondLife* panel = static_cast<LLPanelProfileSecondLife*>(handle->get());
if (result.notNull())
{
panel->setProfileImageUploaded(result);
}
else
{
// failure, just stop progress indicator
panel->setProfileImageUploading(false);
}
break;
}
case PROFILE_IMAGE_FL:
{
LLPanelProfileFirstLife* panel = static_cast<LLPanelProfileFirstLife*>(handle->get());
if (result.notNull())
{
panel->setProfileImageUploaded(result);
}
else
{
// failure, just stop progress indicator
panel->setProfileImageUploading(false);
}
break;
}
}
}

if (type == PROFILE_IMAGE_SL && result.notNull())
{
LLAvatarIconIDCache::getInstance()->add(gAgentID, result);
// Should trigger callbacks in icon controls
LLAvatarPropertiesProcessor::getInstance()->sendAvatarPropertiesRequest(gAgentID);
}

// Cleanup
LLFile::remove(path_to_image);
delete handle;
}


///----------------------------------------------------------------------------
/// LLFloaterProfilePermissions
///----------------------------------------------------------------------------
Expand Down

0 comments on commit bc9b6a3

Please # to comment.