std::string LLTeleportHistoryFlatItem::getTimestamp()
{
	const LLDate &date = mDate;
	std::string timestamp = "";

	LLDate now = LLDate::now();
	S32 now_year, now_month, now_day, now_hour, now_min, now_sec;
	now.split(&now_year, &now_month, &now_day, &now_hour, &now_min, &now_sec);

	const S32 seconds_in_day = 24 * 60 * 60;
	S32 seconds_today = now_hour * 60 * 60 + now_min * 60 + now_sec;
	S32 time_diff = (S32) now.secondsSinceEpoch() - (S32) date.secondsSinceEpoch();

	// Only show timestamp for today and yesterday
	if(time_diff < seconds_today + seconds_in_day)
	{
		timestamp = "[" + LLTrans::getString("TimeHour12")+"]:["
						+ LLTrans::getString("TimeMin")+"] ["+ LLTrans::getString("TimeAMPM")+"]";
		LLSD substitution;
		substitution["datetime"] = (S32) date.secondsSinceEpoch();
		LLStringUtil::format(timestamp, substitution);
	}

	return timestamp;

}
void LLAvatarIconIDCache::load	()
{
	llinfos << "Loading avatar icon id cache." << llendl;
	
	// build filename for each user
	std::string resolved_filename = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, mFilename);
	llifstream file(resolved_filename);

	if (!file.is_open())
		return;
	
	// add each line in the file to the list
	int uuid_len = UUID_STR_LENGTH-1;
	std::string line;
	while (std::getline(file, line)) 
	{
		LLUUID avatar_id;
		LLUUID icon_id;
		LLDate date;

		std::string avatar_id_str = line.substr(0,uuid_len);
		std::string icon_id_str = line.substr(uuid_len,uuid_len);
		
		std::string date_str = line.substr(uuid_len*2, line.length()-uuid_len*2);

		if(!avatar_id.set(avatar_id_str) || !icon_id.set(icon_id_str) || !date.fromString(date_str))
			continue;

		LLAvatarIconIDCacheItem item = {icon_id,date};
		mCache[avatar_id] = item;
	}

	file.close();
	
}
//static
void LLFloaterBlacklist::addEntry(LLUUID key, LLSD data)
{
	if(key.notNull())
	{
		if(!data.has("entry_type")) 
			LL_WARNS("FloaterBlacklistAdd") << "addEntry called with no entry type, specify LLAssetType::Etype" << LL_ENDL;
		else if(!data.has("entry_name"))
			LL_WARNS("FloaterBlacklistAdd") << "addEntry called with no entry name, specify the name that should appear in the listing for this entry." << LL_ENDL;
		else
		{
			if(!data.has("entry_date"))
			{
				LLDate* curdate = new LLDate(time_corrected());
				std::string input_date = curdate->asString();
				input_date.replace(input_date.find("T"),1," ");
				input_date.resize(input_date.size() - 1);
				data["entry_date"] = input_date;
			}
			if(data["entry_type"].asString() == "1")
			{
			  //remove sounds
			  LLUUID sound_id=LLUUID(key);
			  gVFS->removeFile(sound_id,LLAssetType::AT_SOUND);
			  std::string wav_path= gDirUtilp->getExpandedFilename(LL_PATH_CACHE,sound_id.asString()) + ".dsf";
			  if(LLAPRFile::isExist(wav_path, LL_APR_RPB))
				LLAPRFile::remove(wav_path);
			  gAudiop->removeAudioData(sound_id);
			}
			blacklist_entries.insert(std::pair<LLUUID,LLSD>(key,data));
			updateBlacklists();
		}
	}
	else
		LL_WARNS("FloaterBlacklistAdd") << "addEntry called with a null entry key, please specify LLUUID of asset." << LL_ENDL;
}
void LLNotification::init(const std::string& template_name, const LLSD& form_elements)
{
	mTemplatep = LLNotifications::instance().getTemplate(template_name);
	if (!mTemplatep) return;

	// add default substitutions
	// TODO: change this to read from the translatable strings file!
	mSubstitutions["SECOND_LIFE"] = "Second Life";
	mSubstitutions["_URL"] = getURL();
	mSubstitutions["_NAME"] = template_name;
	// TODO: something like this so that a missing alert is sensible:
	//mSubstitutions["_ARGS"] = get_all_arguments_as_text(mSubstitutions);

	mForm = LLNotificationFormPtr(new LLNotificationForm(*mTemplatep->mForm));
	mForm->append(form_elements);

	// apply substitution to form labels
	mForm->formatElements(mSubstitutions);

	LLDate rightnow = LLDate::now();
	if (mTemplatep->mExpireSeconds)
	{
		mExpiresAt = LLDate(rightnow.secondsSinceEpoch() + mTemplatep->mExpireSeconds);
	}

	if (mPriority == NOTIFICATION_PRIORITY_UNSPECIFIED)
	{
		mPriority = mTemplatep->mPriority;
	}
}
Example #5
0
	void date_test_object_t::test<3>()
	{
		LLDate date;
		std::istringstream stream(VALID_DATE);
		std::string  expected_string = VALID_DATE;
		date.fromStream(stream);
		ensure_equals("fromStream failed", date.asString(), expected_string);
	}
Example #6
0
	void date_test_object_t::test<2>()
	{
#if LL_DATE_PARSER_CHECKS_BOUNDARY
		LLDate date;
		std::string  expected_string;
		bool result;

		result = date.fromString(INVALID_DATE_24HOUR_BOUNDARY);
		ensure_equals("INVALID_DATE_24HOUR_BOUNDARY should have failed" , result, false);
		ensure_equals("INVALID_DATE_24HOUR_BOUNDARY date still set to old value on failure!" , date.secondsSinceEpoch(), 0);

		result = date.fromString(INVALID_DATE_LEAP);
		ensure_equals("INVALID_DATE_LEAP should have failed" , result, false);

		result = date.fromString(INVALID_DATE_HOUR);
		ensure_equals("INVALID_DATE_HOUR should have failed" , result, false);

		result = date.fromString(INVALID_DATE_MIN);
		ensure_equals("INVALID_DATE_MIN should have failed" , result, false);

		result = date.fromString(INVALID_DATE_SEC);
		ensure_equals("INVALID_DATE_SEC should have failed" , result, false);

		result = date.fromString(INVALID_DATE_YEAR);
		ensure_equals("INVALID_DATE_YEAR should have failed" , result, false);

		result = date.fromString(INVALID_DATE_MONTH);
		ensure_equals("INVALID_DATE_MONTH should have failed" , result, false);

		result = date.fromString(INVALID_DATE_DAY);
		ensure_equals("INVALID_DATE_DAY should have failed" , result, false);
#endif
	}
void LLAvatarName::fromLLSD(const LLSD& sd)
{
	mUsername = sd[USERNAME].asString();
	mDisplayName = sd[DISPLAY_NAME].asString();
	mLegacyFirstName = sd[LEGACY_FIRST_NAME].asString();
	mLegacyLastName = sd[LEGACY_LAST_NAME].asString();
	mIsDisplayNameDefault = sd[IS_DISPLAY_NAME_DEFAULT].asBoolean();
	LLDate expires = sd[DISPLAY_NAME_EXPIRES];
	mExpires = expires.secondsSinceEpoch();
	LLDate next_update = sd[DISPLAY_NAME_NEXT_UPDATE];
	mNextUpdate = next_update.secondsSinceEpoch();
}
Example #8
0
	void date_test_object_t::test<7>()
	{
		LLDate date;
		std::istringstream stream(VALID_DATE);
		stream >> date;
		std::string expected_str = VALID_DATE;
		std::ostringstream out_stream;
        out_stream << date;

		ensure_equals("<< failed", date.asString(),expected_str);
		ensure_equals("<< to >> failed", stream.str(),out_stream.str());		
	}
bool LLDateUtil::dateFromPDTString(LLDate& date, const std::string& str)
{
	S32 month, day, year;
	S32 matched = sscanf(str.c_str(), "%d/%d/%d", &month, &day, &year);
	if (matched != 3) return false;
	date.fromYMDHMS(year, month, day);
	F64 secs_since_epoch = date.secondsSinceEpoch();
	// Correct for the fact that specified date is in Pacific time, == UTC - 8
	secs_since_epoch += 8.0 * 60.0 * 60.0;
	date.secondsSinceEpoch(secs_since_epoch);
	return true;
}
	void SDTestObject::test<7>()
		// Test assignment and casting to various scalar types.  These
		// assignments should invoke the right conversion without it being
		// mentioned explicitly.  The few exceptions are marked SAD.
	{
		SDCleanupCheck check;
		
		LLSD v("  42.375");
		
		bool b = false;
		b = v;				ensure_equals("assign to bool", b, true);
		b = (bool)v;		ensure_equals("cast to bool", b, true);
		
		int i = 99;
		i = v;				ensure_equals("assign to int", i, 42);
		i = (int)v;			ensure_equals("cast to int", i, 42);
		
		double d = 3.14159;
		d = v;				ensure_equals("assign to double", d, 42.375);
		d = (double)v;		ensure_equals("cast to double", d, 42.375);
		
		std::string s = "yo";
// SAD	s = v;				ensure_equals("assign to string", s, "  42.375");
		s = (std::string)v;	ensure_equals("cast to string", s, "  42.375");

		std::string uuidStr = "b1e50c2b-b627-4d23-8a86-a65d97b6319b";
		v = uuidStr;
		LLUUID u;
		u = v;
					ensure_equals("assign to LLUUID", u, LLUUID(uuidStr));
// SAD	u = (LLUUID)v;
//					ensure_equals("cast to LLUUID", u, LLUUID(uuidStr));
		
		std::string dateStr = "2005-10-24T15:00:00Z";
		v = dateStr;
		LLDate date;
		date = v;
					ensure_equals("assign to LLDate", date.asString(), dateStr);
// SAD	date = (LLDate)v;
//					ensure_equals("cast to LLDate", date.asString(), dateStr);
		
		std::string uriStr = "http://secondlife.com";
		v = uriStr;
		LLURI uri;
		uri = v;
					ensure_equals("assign to LLURI", uri.asString(), uriStr);
// SAD 	uri = (LLURI)v;
//					ensure_equals("cast to LLURI", uri.asString(), uriStr);
	}
void FSWSAssetBlacklist::addNewItemToBlacklist(LLUUID id, std::string name, std::string region, LLAssetType::EType type, bool save)
{
	LLDate curdate = LLDate(time_corrected());
	std::string input_date = curdate.asString();
	input_date.replace(input_date.find("T"),1," ");
	input_date.resize(input_date.size() - 1);
	
	LLSD data;
	data["asset_name"] = name;
	data["asset_region"] = region;
	data["asset_type"] = type;
	data["asset_date"] = input_date;

	addNewItemToBlacklistData(LLUUID::generateNewID(id.asString() + "hash"), data, save);
}
void LLTeleportHistoryFlatItem::updateTitle()
{
	static LLUIColor sFgColor = LLUIColorTable::instance().getColor("MenuItemEnabledColor", LLColor4U(255, 255, 255));

	LLTextUtil::textboxSetHighlightedVal(
		mTitle,
		LLStyle::Params().color(sFgColor),
		mRegionName,
		mHighlight);

	// <FS:Ansariel> Extended TP history
	LLTextUtil::textboxSetHighlightedVal(
		mLocalPosBox,
		LLStyle::Params().color(sFgColor),
		llformat("%.0f, %.0f, %.0f", mLocalPos.mV[VX], mLocalPos.mV[VY], mLocalPos.mV[VZ]),
		mHighlight);

	LLSD args;
	args["datetime"] = mDate.secondsSinceEpoch();
	std::string date = getString("DateFmt");
	LLStringUtil::format(date, args);

	LLTextUtil::textboxSetHighlightedVal(
		mTimeTextBox,
		LLStyle::Params().color(sFgColor),
		date,
		mHighlight);
	// </FS:Ansariel>
}
void FSWSAssetBlacklist::addNewItemToBlacklist(const LLUUID& id, const std::string& name, const std::string& region, LLAssetType::EType type, bool save)
{
	if (isBlacklisted(id, type))
	{
		return;
	}

	LLDate curdate = LLDate(time_corrected());
	std::string input_date = curdate.asString();
	input_date.replace(input_date.find("T"), 1, " ");
	input_date.resize(input_date.size() - 1);
	
	LLSD data;
	data["asset_name"] = name;
	data["asset_region"] = region;
	data["asset_type"] = type;
	data["asset_date"] = input_date;

	addNewItemToBlacklistData(id, data, save);
}
/////////////////////////////////////////////////////////////////////////////////////////
// static
void LLViewerMedia::addCookie(const std::string &name, const std::string &value, const std::string &domain, const LLDate &expires, const std::string &path, bool secure)
{
	std::stringstream cookie;
	
	cookie << name << "=" << LLPluginCookieStore::quoteString(value);
	
	if(expires.notNull())
	{
		cookie << "; expires=" << expires.asRFC1123();
	}
	
	cookie << "; domain=" << domain;

	cookie << "; path=" << path;
	
	if(secure)
	{
		cookie << "; secure";
	}
	
	getCookieStore()->setCookies(cookie.str());
}
void LLNotification::init(const std::string& template_name, const LLSD& form_elements)
{
	mTemplatep = LLNotificationTemplates::instance().getTemplate(template_name);
	if (!mTemplatep) return;

	const LLStringUtil::format_map_t& default_args = LLTrans::getDefaultArgs();
	for (LLStringUtil::format_map_t::const_iterator iter = default_args.begin();
		 iter != default_args.end(); ++iter)
	{
		mSubstitutions[iter->first] = iter->second;
	}
	mSubstitutions["_URL"] = getURL();
	mSubstitutions["_NAME"] = template_name;

	// TODO: something like this so that a missing alert is sensible:
	//mSubstitutions["_ARGS"] = get_all_arguments_as_text(mSubstitutions);

	mForm = LLNotificationFormPtr(new LLNotificationForm(*mTemplatep->mForm));
	mForm->append(form_elements);

	// apply substitution to form labels
	mForm->formatElements(mSubstitutions);

	mIgnored = mForm->getIgnored();

	LLDate rightnow = LLDate::now();
	if (mTemplatep->mExpireSeconds)
	{
		mExpiresAt = LLDate(rightnow.secondsSinceEpoch() + mTemplatep->mExpireSeconds);
	}

	if (mPriority == NOTIFICATION_PRIORITY_UNSPECIFIED)
	{
		mPriority = mTemplatep->mPriority;
	}
}
Example #16
0
void LLNotification::init(const std::string& template_name, const LLSD& form_elements)
{
	mTemplatep = LLNotifications::instance().getTemplate(template_name);
	if (!mTemplatep) return;

	// add default substitutions
	mSubstitutions["[SECOND_LIFE]"] = LLNotifications::instance().getGlobalString("SECOND_LIFE");
	mSubstitutions["[VIEWER_NAME]"] = LLNotifications::instance().getGlobalString("VIEWER_NAME");
	mSubstitutions["[VIEWER_SITE]"] = LLNotifications::instance().getGlobalString("VIEWER_SITE");

	mSubstitutions["[GRID_NAME]"] = gHippoGridManager->getConnectedGrid()->getGridName();
	mSubstitutions["[GRID_SITE]"] = gHippoGridManager->getConnectedGrid()->getWebSite();
	mSubstitutions["[CURRENCY]"] = gHippoGridManager->getConnectedGrid()->getCurrencySymbol();

	mSubstitutions["_URL"] = getURL();
	mSubstitutions["_NAME"] = template_name;
	// TODO: something like this so that a missing alert is sensible:
	//mSubstitutions["_ARGS"] = get_all_arguments_as_text(mSubstitutions);

	mForm = LLNotificationFormPtr(new LLNotificationForm(*mTemplatep->mForm));
	mForm->append(form_elements);

	// apply substitution to form labels
	mForm->formatElements(mSubstitutions);

	LLDate rightnow = LLDate::now();
	if (mTemplatep->mExpireSeconds)
	{
		mExpiresAt = LLDate(rightnow.secondsSinceEpoch() + mTemplatep->mExpireSeconds);
	}

	if (mPriority == NOTIFICATION_PRIORITY_UNSPECIFIED)
	{
		mPriority = mTemplatep->mPriority;
	}
}
std::string LLDateUtil::ageFromDate(const LLDate& born_date, const LLDate& now)
{
	S32 born_month, born_day, born_year;
	// explode out to month/day/year again
	born_date.split(&born_year, &born_month, &born_day);

	S32 now_year, now_month, now_day;
	now.split(&now_year, &now_month, &now_day);

	// Do grade-school subtraction, from right-to-left, borrowing from the left
	// when things go negative
	S32 age_days = (now_day - born_day);
	if (age_days < 0)
	{
		now_month -= 1;
		if (now_month == 0)
		{
			now_year -= 1;
			now_month = 12;
		}
		age_days += days_from_month(now_year, now_month);
	}
	S32 age_months = (now_month - born_month);
	if (age_months < 0)
	{
		now_year -= 1;
		age_months += 12;
	}
	S32 age_years = (now_year - born_year);

	// Noun pluralization depends on language
	std::string lang = LLUI::getLanguage();

	// Try for age in round number of years
	LLStringUtil::format_map_t args;

	if (age_months > 0 || age_years > 0)
	{
		args["[AGEYEARS]"] =
			LLTrans::getCountString(lang, "AgeYears", age_years);
		args["[AGEMONTHS]"] =
			LLTrans::getCountString(lang, "AgeMonths", age_months);

		// We want to display times like:
		// 2 year 2 months
		// 2 years (implicitly 0 months)
		// 11 months
		if (age_years > 0)
		{
			if (age_months > 0)
			{
				return LLTrans::getString("YearsMonthsOld", args);
			}
			else
			{
				return LLTrans::getString("YearsOld", args);
			}
		}
		else // age_years == 0
		{
			return LLTrans::getString("MonthsOld", args);
		}
	}
	// you're 0 months old, display in weeks or days

	// Now for age in weeks
	S32 age_weeks = age_days / 7;
	age_days = age_days % 7;
	if (age_weeks > 0)
	{
		args["[AGEWEEKS]"] = 
			LLTrans::getCountString(lang, "AgeWeeks", age_weeks);
		return LLTrans::getString("WeeksOld", args);
	}

	// Down to days now
	if (age_days > 0)
	{
		args["[AGEDAYS]"] =
			LLTrans::getCountString(lang, "AgeDays", age_days);
		return LLTrans::getString("DaysOld", args);
	}

	return LLTrans::getString("TodayOld");
}
Example #18
0
void LLTeleportHistoryPanel::getNextTab(const LLDate& item_date, S32& tab_idx, LLDate& tab_date)
{
	const U32 seconds_in_day = 24 * 60 * 60;

	S32 tabs_cnt = mItemContainers.size();
	S32 curr_year = 0, curr_month = 0, curr_day = 0;

	tab_date = LLDate::now();
	tab_date.split(&curr_year, &curr_month, &curr_day);
	tab_date.fromYMDHMS(curr_year, curr_month, curr_day); // Set hour, min, and sec to 0
	tab_date.secondsSinceEpoch(tab_date.secondsSinceEpoch() + seconds_in_day);

	tab_idx = -1;

	while (tab_idx < tabs_cnt - 1 && item_date < tab_date)
	{
		tab_idx++;

		if (tab_idx <= tabs_cnt - 4)
		{
			// All tabs, except last three, are tabs for one day, so just push tab_date back by one day
			tab_date.secondsSinceEpoch(tab_date.secondsSinceEpoch() - seconds_in_day);
		}
		else if (tab_idx == tabs_cnt - 3) // 6 day and older, low boundary is 1 month
		{
			tab_date =  LLDate::now();
			tab_date.split(&curr_year, &curr_month, &curr_day);
			curr_month--;
			if (0 == curr_month)
			{
				curr_month = 12;
				curr_year--;
			}
			tab_date.fromYMDHMS(curr_year, curr_month, curr_day);
		}
		else if (tab_idx == tabs_cnt - 2) // 1 month and older, low boundary is 6 months
		{
			tab_date =  LLDate::now();
			tab_date.split(&curr_year, &curr_month, &curr_day);
			if (curr_month > 6)
			{
				curr_month -= 6;
			}
			else
			{
				curr_month += 6;
				curr_year--;
			}
			tab_date.fromYMDHMS(curr_year, curr_month, curr_day);
		}
		else // 6 months and older
		{
			tab_date.secondsSinceEpoch(0);
		}
	}
}
Example #19
0
LLEventTimer::LLEventTimer(const LLDate& time)
: mEventTimer()
{
	mPeriod = (F32)(time.secondsSinceEpoch() - LLDate::now().secondsSinceEpoch());
}
LLGroupNotifyBox::LLGroupNotifyBox(const std::string& subject,
							 const std::string& message,
							 const std::string& from_name,
							 const LLUUID& group_id,
							 const LLUUID& group_insignia,
							 const std::string& group_name,
							 const LLDate& time_stamp,
							 const bool& has_inventory,
							 const std::string& inventory_name,
							 const LLSD& inventory_offer)
:	LLPanel("groupnotify", LLGroupNotifyBox::getGroupNotifyRect(), BORDER_YES),
	mAnimating(TRUE),
	mTimer(),
	mGroupID(group_id),
	mHasInventory(has_inventory),
	mInventoryOffer(NULL)
{
	const S32 VPAD = 2;
	const S32 TOP = getRect().getHeight() - 32; // Get past the top menu bar
	const S32 BOTTOM_PAD = VPAD * 2;
	const S32 BTN_TOP = BOTTOM_PAD + BTN_HEIGHT + VPAD;
	const S32 RIGHT = getRect().getWidth() - HPAD - HPAD;
	const S32 LINE_HEIGHT = 16;

	const S32 LABEL_WIDTH = 64;
	const S32 ICON_WIDTH = 64;

  	time_t timestamp = (time_t)time_stamp.secondsSinceEpoch();
 	if (!timestamp) time(&timestamp);

	std::string time_buf;
	timeToFormattedString(timestamp, gSavedSettings.getString("TimestampFormat"), time_buf);

	if (mHasInventory)
	{
		mInventoryOffer = new LLOfferInfo(inventory_offer);
	}

	setFocusRoot(TRUE);
	setFollows(FOLLOWS_TOP|FOLLOWS_RIGHT);
	setBackgroundVisible(TRUE);
	setBackgroundOpaque(TRUE);
	setBackgroundColor( gColors.getColor("GroupNotifyBoxColor") );

	LLIconCtrl* icon;
	LLTextEditor* text;

	S32 y = TOP;
	S32 x = HPAD + HPAD;

	class NoticeText : public LLTextBox
	{
	public:
		NoticeText(const std::string& name, const LLRect& rect, const std::string& text = LLStringUtil::null, const LLFontGL* font = NULL) 
			: LLTextBox(name, rect, text, font)
		{
			setHAlign(LLFontGL::RIGHT);
			setFontShadow(LLFontGL::DROP_SHADOW_SOFT);
			setBorderVisible(FALSE);
			setColor( gColors.getColor("GroupNotifyTextColor") );
			setBackgroundColor( gColors.getColor("GroupNotifyBoxColor") );
		}
	};

	// Title
	addChild(new NoticeText(std::string("title"),LLRect(x,y,RIGHT - HPAD,y - LINE_HEIGHT),LLTrans::getString("GroupNotifyGroupNotice"),LLFontGL::getFontSansSerifHuge()));

	y -= llfloor(1.5f*LINE_HEIGHT);

	x += HPAD + HPAD + ICON_WIDTH;

	std::stringstream from;
	from << LLTrans::getString("GroupNotifySentBy") << " " + from_name << LLTrans::getString(",") + " " << group_name;

	addChild(new NoticeText(std::string("group"),LLRect(x,y,RIGHT - HPAD,y - LINE_HEIGHT),from.str(),LLFontGL::getFontSansSerif()));
	
	y -= (LINE_HEIGHT + VPAD);
	x = HPAD + HPAD;

	// TODO: change this to be the group icon.
	if (!group_insignia.isNull())
	{
		icon = new LLIconCtrl(std::string("icon"),
							  LLRect(x, y, x+ICON_WIDTH, y-ICON_WIDTH),
							  group_insignia.asString());
	}
	else
	{
		icon = new LLIconCtrl(std::string("icon"),
							  LLRect(x, y, x+ICON_WIDTH, y-ICON_WIDTH),
							  std::string("notify_box_icon.tga"));
	}

	icon->setMouseOpaque(FALSE);
	addChild(icon);

	x += HPAD + HPAD + ICON_WIDTH;
	// If we have inventory with this message, leave room for the name.
	S32 box_bottom = BTN_TOP + (mHasInventory ? (LINE_HEIGHT + 2*VPAD) : 0);

	text = new LLViewerTextEditor(std::string("box"),
		LLRect(x, y, RIGHT, box_bottom),
		DB_GROUP_NOTICE_MSG_STR_LEN,
		LLStringUtil::null,
		LLFontGL::getFontSansSerif(),
		FALSE);

	static const LLStyleSP headerstyle(new LLStyle(true,LLColor4::black,"SansSerifBig"));
	static const LLStyleSP datestyle(new LLStyle(true,LLColor4::black,"serif"));

	text->appendStyledText(subject + "\n",false,false,headerstyle);

	text->appendStyledText(time_buf,false,false,datestyle);
	// Sadly, our LLTextEditor can't handle both styled and unstyled text
	// at the same time.  Hence this space must be styled. JC
	text->appendColoredText(std::string(" "),false,false,LLColor4::grey4);
	text->setParseHTML(TRUE);
	text->appendColoredText(std::string("\n\n") + message,false,false,LLColor4::grey4);

	LLColor4 semi_transparent(1.0f,1.0f,1.0f,0.8f);
	text->setCursor(0,0);
	text->setEnabled(FALSE);
	text->setWordWrap(TRUE);
	//text->setTabStop(FALSE); // was interfering with copy-and-paste
	text->setTabsToNextField(TRUE);
	text->setMouseOpaque(TRUE);
	text->setBorderVisible(TRUE);
	text->setTakesNonScrollClicks(TRUE);
	text->setHideScrollbarForShortDocs(TRUE);
	text->setReadOnlyBgColor ( semi_transparent );
	text->setWriteableBgColor ( semi_transparent );
	
	addChild(text);

	y = box_bottom - VPAD;

	if (mHasInventory)
	{
			addChild(new NoticeText(std::string("subjecttitle"),LLRect(x,y,x + LABEL_WIDTH,y - LINE_HEIGHT),LLTrans::getString("GroupNotifyAttached"),LLFontGL::getFontSansSerif()));

			LLUIImagePtr item_icon = LLInventoryIcon::getIcon(mInventoryOffer->mType,
													LLInventoryType::IT_TEXTURE,
													0, FALSE);


			x += LABEL_WIDTH + HPAD;

			std::stringstream ss;
			ss << "        " << inventory_name;
			LLTextBox *line = new LLTextBox(std::string("object_name"),LLRect(x,y,RIGHT - HPAD,y - LINE_HEIGHT),ss.str(),LLFontGL::getFontSansSerif());
			line->setEnabled(FALSE);
			line->setBorderVisible(TRUE);
			line->setDisabledColor(LLColor4::blue4);
			line->setFontStyle(LLFontGL::NORMAL);
			line->setBackgroundVisible(true);
			line->setBackgroundColor( semi_transparent );
			addChild(line);

			icon = new LLIconCtrl(std::string("icon"),
									LLRect(x, y, x+16, y-16),
									item_icon->getName());
			icon->setMouseOpaque(FALSE);
			addChild(icon);
	}

	LLButton* btn;
	btn = new LLButton(LLTrans::getString("next"),
				LLRect(getRect().getWidth()-26, BOTTOM_PAD + 20, getRect().getWidth()-2, BOTTOM_PAD),
				std::string("notify_next.png"),
				std::string("notify_next.png"),
				LLStringUtil::null,
				boost::bind(&LLGroupNotifyBox::onClickNext, this),
				LLFontGL::getFontSansSerif());
	btn->setToolTip(LLTrans::getString("next"));
	btn->setScaleImage(TRUE);
	addChild(btn);
	mNextBtn = btn;

	S32 btn_width = 80;
	S32 wide_btn_width = 120;
	LLRect btn_rect;
	x = 3 * HPAD;

	btn_rect.setOriginAndSize(x,
								BOTTOM_PAD,
								btn_width,
								BTN_HEIGHT);

	btn = new LLButton(LLTrans::getString("ok"), btn_rect, LLStringUtil::null, boost::bind(&LLGroupNotifyBox::onClickOk,this));
	addChild(btn, -1);
	setDefaultBtn(btn);

	x += btn_width + HPAD;

	
	btn_rect.setOriginAndSize(x,
								BOTTOM_PAD,
								wide_btn_width,
								BTN_HEIGHT);

	btn = new LLButton(LLTrans::getString("GroupNotifyGroupNotices"), btn_rect, LLStringUtil::null, boost::bind(LLGroupActions::showTab, mGroupID, "notices_tab"));
	btn->setToolTip(LLTrans::getString("GroupNotifyViewPastNotices"));
	addChild(btn, -1);

	if (mHasInventory)
	{
		x += wide_btn_width + HPAD;

		btn_rect.setOriginAndSize(x,
									BOTTOM_PAD,
									wide_btn_width,
									BTN_HEIGHT);

		std::string btn_lbl("");
		if(is_openable(mInventoryOffer->mType))
		{
			btn_lbl = LLTrans::getString("GroupNotifyOpenAttachment");
		}
		else
		{
			btn_lbl = LLTrans::getString("GroupNotifySaveAttachment");
		}
		mSaveInventoryBtn = new LLButton(btn_lbl, btn_rect, LLStringUtil::null, boost::bind(&LLGroupNotifyBox::onClickSaveInventory,this));
		mSaveInventoryBtn->setVisible(mHasInventory);
		addChild(mSaveInventoryBtn);
	}

	sGroupNotifyBoxCount++;

	// If this is the only notify box, don't show the next button
	if (sGroupNotifyBoxCount == 1)
	{
		mNextBtn->setVisible(FALSE);
	}
}
Example #21
0
	void ensure_equals(const std::string& msg, const LLDate& actual,
		const LLDate& expected)
	{
		ensure_equals(msg,
			actual.secondsSinceEpoch(), expected.secondsSinceEpoch());
	}
Example #22
0
	void ensure_equals(const char* msg, const LLDate& actual,
		const LLDate& expected)
	{
		ensure_equals(msg,
			actual.secondsSinceEpoch(), expected.secondsSinceEpoch());
	}
Example #23
0
//
// LLGridManager::addGrid - add a grid to the grid list, populating the needed values
// if they're not populated yet.
//
void LLGridManager::addGrid(GridEntry* grid_entry,  AddState state)
{
	if(!grid_entry)
	{
		llwarns << "addGrid called with NULL grid_entry. Please send a bug report." << llendl;
		state = FAIL;
	}
	if(!grid_entry->grid.has(GRID_VALUE))
	{
		state = FAIL;
	}
	else if(grid_entry->grid[GRID_VALUE].asString().empty())
	{
		state = FAIL;
	}
	else if(!grid_entry->grid.isMap())
	{
		state = FAIL;
	}

	if ((FETCH == state) ||(FETCHTEMP == state) || (SYSTEM == state))
	{
		std::string grid = utf8str_tolower(grid_entry->grid[GRID_VALUE]);
		// grid should be in the form of a dns address
		// but also support localhost:9000 or localhost:9000/login
		if ( !grid.empty() && grid.find_first_not_of("abcdefghijklmnopqrstuvwxyz1234567890-_.:/@% ") != std::string::npos)
		{
			printf("grid name: %s", grid.c_str());
			if (grid_entry)
			{
				state = FAIL;
				delete grid_entry;
				grid_entry = NULL;
			}
			throw LLInvalidGridName(grid);
		}

		size_t find_last_slash = grid.find_last_of("/");
		if ( (grid.length()-1) == find_last_slash )
		{
			grid.erase(find_last_slash);
			grid_entry->grid[GRID_VALUE]  = grid;
		}

		if (FETCHTEMP == state)
		{
			grid_entry->grid["FLAG_TEMPORARY"] = "TRUE";
			state = FETCH;
		}

	}

	if ((FETCH == state) || (RETRY == state))
	{
		std::string grid = utf8str_tolower(grid_entry->grid[GRID_VALUE]);


		std::string match = "://";
		size_t find_scheme = grid.find(match);
		if ( std::string::npos != find_scheme)
		{
			// We only support http so just remove anything the user might have chosen
			grid.erase(0,find_scheme+match.length());
			grid_entry->grid[GRID_VALUE]  = grid;
		}

		std::string uri = "http://"+grid;

		if (std::string::npos != uri.find("lindenlab.com"))
		{
			state = SYSTEM;
		}
		else
		{
			if ( std::string::npos == uri.find(".")
				|| std::string::npos != uri.find("127.0.0.1")
				|| std::string::npos != uri.find("localhost") )
			{
				state = LOCAL;
			}
			grid_entry->grid[GRID_LOGIN_URI_VALUE] = LLSD::emptyArray();
			grid_entry->grid[GRID_LOGIN_URI_VALUE].append(uri);

			size_t find_last_slash = uri.find_last_of("/");
			if ( (uri.length()-1) != find_last_slash )
			{
				uri.append("/");
			}
			uri.append("get_grid_info");
	
			LL_DEBUGS("GridManager") << "get_grid_info uri: " << uri << LL_ENDL;
	
			time_t last_modified = 0;
			if(grid_entry->grid.has("LastModified"))
			{
				LLDate saved_value = grid_entry->grid["LastModified"];
				last_modified = (time_t)saved_value.secondsSinceEpoch();
			}
	
			LLHTTPClient::getIfModified(uri, new GridInfoRequestResponder(this, grid_entry, state), last_modified);
			return;
		}
	}

	if(TRYLEGACY == state)
	{
		std::string grid = utf8str_tolower(grid_entry->grid[GRID_VALUE]);
		std::string uri = "https://" + grid + "/cgi-bin/login.cgi";
		llwarns << "No gridinfo found. Trying if legacy login page exists: " << uri << llendl;
		LLHTTPClient::get(uri, new GridInfoRequestResponder(this, grid_entry, state));
		return;
	}

	if(FAIL != state)
	{
		std::string grid = utf8str_tolower(grid_entry->grid[GRID_VALUE]);

		// populate the other values if they don't exist
		if (!grid_entry->grid.has(GRID_LABEL_VALUE)) 
		{
			grid_entry->grid[GRID_LABEL_VALUE] = grid;
			llwarns << "No \"gridname\" found in grid info, setting to " << grid_entry->grid[GRID_LABEL_VALUE].asString() << llendl;
		}


		if (!grid_entry->grid.has(GRID_NICK_VALUE))
		{
			grid_entry->grid[GRID_NICK_VALUE] = grid;
			llwarns << "No \"gridnick\" found in grid info, setting to " << grid_entry->grid[GRID_NICK_VALUE].asString() << llendl;
		}
	}

	if (SYSTEM == state)
	{
		std::string grid = utf8str_tolower(grid_entry->grid[GRID_VALUE]);

		// if the grid data doesn't include any of the URIs, then 
		// generate them from the grid

		if (!grid_entry->grid.has(GRID_LOGIN_URI_VALUE))
		{
			grid_entry->grid[GRID_LOGIN_URI_VALUE] = LLSD::emptyArray();
			grid_entry->grid[GRID_LOGIN_URI_VALUE].append(std::string("https://") + grid + "/cgi-bin/login.cgi");
			llwarns << "Adding Legacy Login Service at:" << grid_entry->grid[GRID_LOGIN_URI_VALUE].asString() << llendl;
		}

		// Populate to the default values
		if (!grid_entry->grid.has(GRID_LOGIN_PAGE_VALUE)) 
		{
			grid_entry->grid[GRID_LOGIN_PAGE_VALUE] = std::string("http://") + grid + "/app/login/";
			llwarns << "Adding Legacy Login Screen at:" << grid_entry->grid[GRID_LOGIN_PAGE_VALUE].asString() << llendl;
		}		
		if (!grid_entry->grid.has(GRID_HELPER_URI_VALUE)) 
		{
			llwarns << "Adding Legacy Economy at:" << grid_entry->grid[GRID_HELPER_URI_VALUE].asString() << llendl;
			grid_entry->grid[GRID_HELPER_URI_VALUE] = std::string("https://") + grid + "/helpers/";
		}
	}

	if(FAIL != state)
	{
		std::string grid = utf8str_tolower(grid_entry->grid[GRID_VALUE]);

		if (!grid_entry->grid.has(GRID_LOGIN_IDENTIFIER_TYPES))
		{
			// non system grids and grids that haven't already been configured with values
			// get both types of credentials.
			grid_entry->grid[GRID_LOGIN_IDENTIFIER_TYPES] = LLSD::emptyArray();
			grid_entry->grid[GRID_LOGIN_IDENTIFIER_TYPES].append(CRED_IDENTIFIER_TYPE_AGENT);
			grid_entry->grid[GRID_LOGIN_IDENTIFIER_TYPES].append(CRED_IDENTIFIER_TYPE_ACCOUNT);
		}
	
		bool is_current = grid_entry->set_current;
		grid_entry->set_current = false;
	
		if(!grid.empty())//
		{
			if (!mGridList.has(grid)) //new grid
			{
				//finally add the grid \o/
				mGridList[grid] = grid_entry->grid;
				++mGridEntries;

				LL_DEBUGS("GridManager") << "Adding new entry: " << grid << LL_ENDL;
			}
			else
			{
				LLSD existing_grid = mGridList[grid];
				if (!existing_grid.has("LastModified"))
				{
					//lack of "LastModified" means existing_grid is from fallback list,
					// assume its anyway older and override with the new entry

					mGridList[grid] = grid_entry->grid;
					//number of mGridEntries doesn't change
					LL_DEBUGS("GridManager") << "Using custom entry: " << grid << LL_ENDL;
				}
				else if (grid_entry->grid.has("LastModified"))
				{
// (time_t)saved_value.secondsSinceEpoch();
					LLDate testing_newer = grid_entry->grid["LastModified"];
					LLDate existing = existing_grid["LastModified"];

					LL_DEBUGS("GridManager") << "testing_newer " << testing_newer
								<< " existing " << existing << LL_ENDL;

					if(testing_newer.secondsSinceEpoch() > existing.secondsSinceEpoch())
					{
						//existing_grid is older, override.
	
						mGridList[grid] = grid_entry->grid;
						//number of mGridEntries doesn't change
						LL_DEBUGS("GridManager") << "Updating entry: " << grid << LL_ENDL;
					}
				}
				else
				{
					LL_DEBUGS("GridManager") << "Same or newer entry already present: " << grid << LL_ENDL;
				}

			}
	
			if(is_current)
			{
				mGrid = grid;
	
				LL_DEBUGS("GridManager") << "Selected grid is " << mGrid << LL_ENDL;		
				setGridChoice(mGrid);
			}
	
		}
	}

// This is only of use if we want to fetch infos of entire gridlists at startup
/*
	if(grid_entry && FINISH == state || FAIL == state)
	{

		if((FINISH == state && !mCommandLineDone && 0 == mResponderCount)
			||(FAIL == state && grid_entry->set_current) )
		{
			LL_DEBUGS("GridManager") << "init CmdLineGrids"  << LL_ENDL;

			initCmdLineGrids();
		}
	}
*/

	if (grid_entry)
	{
		if(!grid_entry->mOnDoneCallback.empty()) {
			grid_entry->mOnDoneCallback();
		}
		delete grid_entry;
		grid_entry = NULL;
	}
}