1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
/**
* @file llfloatersocial.cpp
* @brief Implementation of llfloatersocial
* @author Gilbert@lindenlab.com
*
* $LicenseInfo:firstyear=2013&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2013, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#include "llviewerprecompiledheaders.h"
#include "llfloatersocial.h"
#include "llagent.h"
#include "llagentui.h"
#include "llfacebookconnect.h"
#include "llfloaterreg.h"
#include "llslurl.h"
#include "llviewerregion.h"
#include "llviewercontrol.h"
static LLRegisterPanelClassWrapper<LLSocialPhotoPanel> t_panel_photo("llsocialphotopanel");
static LLRegisterPanelClassWrapper<LLSocialCheckinPanel> t_panel_checkin("llsocialcheckinpanel");
std::string get_map_url()
{
LLVector3d center_agent;
if (gAgent.getRegion())
{
center_agent = gAgent.getRegion()->getCenterGlobal();
}
int x_pos = center_agent[0] / 256.0;
int y_pos = center_agent[1] / 256.0;
std::string map_url = gSavedSettings.getString("CurrentMapServerURL") + llformat("map-1-%d-%d-objects.jpg", x_pos, y_pos);
return map_url;
}
LLSocialPhotoPanel::LLSocialPhotoPanel()
{
mCommitCallbackRegistrar.add("PostToFacebook.Send", boost::bind(&LLSocialPhotoPanel::onSend, this));
}
void LLSocialPhotoPanel::onSend()
{
std::string caption = getChild<LLUICtrl>("caption")->getValue().asString();
bool add_location = getChild<LLUICtrl>("add_location_cb")->getValue().asBoolean();
if (add_location)
{
LLSLURL slurl;
LLAgentUI::buildSLURL(slurl);
if (caption.empty())
caption = slurl.getSLURLString();
else
caption = caption + " " + slurl.getSLURLString();
}
//LLFacebookConnect::instance().sharePhoto(LLFloaterSnapshot::getImageData(), caption);
//LLWebProfile::uploadImage(LLFloaterSnapshot::getImageData(), caption, add_location, boost::bind(&LLPanelSnapshotFacebook::onImageUploaded, this, caption, _1));
//LLFloaterSnapshot::postSave();
}
LLSocialCheckinPanel::LLSocialCheckinPanel() :
mMapUrl("")
{
mCommitCallbackRegistrar.add("SocialSharing.SendCheckin", boost::bind(&LLSocialCheckinPanel::onSend, this));
}
/*virtual*/
void LLSocialCheckinPanel::setVisible(BOOL visible)
{
if (visible)
{
mMapUrl = get_map_url();
}
LLPanel::setVisible(visible);
}
void LLSocialCheckinPanel::onSend()
{
// Get the location SLURL
LLSLURL slurl;
LLAgentUI::buildSLURL(slurl);
std::string slurl_string = slurl.getSLURLString();
// Get the region name
std::string region_name = gAgent.getRegion()->getName();
// Get the region description
std::string description;
LLAgentUI::buildLocationString(description, LLAgentUI::LOCATION_FORMAT_NORMAL_COORDS, gAgent.getPositionAgent());
// Optionally add the region map view
bool add_map_view = getChild<LLUICtrl>("add_place_view_cb")->getValue().asBoolean();
std::string map_url = (add_map_view ? mMapUrl : "");
// Get the caption
std::string caption = getChild<LLUICtrl>("place_caption")->getValue().asString();
// Post all that to Facebook
LLFacebookConnect::instance().postCheckin(slurl_string, region_name, description, map_url, caption);
// Close the floater once "Post" has been pushed
LLFloater* floater = getParentByType<LLFloater>();
if (floater)
{
floater->closeFloater();
}
}
LLFloaterSocial::LLFloaterSocial(const LLSD& key) : LLFloater(key)
{
mCommitCallbackRegistrar.add("SocialSharing.Cancel", boost::bind(&LLFloaterSocial::onCancel, this));
}
void LLFloaterSocial::onCancel()
{
closeFloater();
}
BOOL LLFloaterSocial::postBuild()
{
return LLFloater::postBuild();
}
|