EMail and Browser integration now enabled upon login.

This commit is contained in:
Robert MacGregor 2015-02-08 00:57:57 -05:00
parent 62c22f43f8
commit aa9d6c9c74
17 changed files with 290 additions and 69 deletions

View file

@ -120,6 +120,14 @@ function CommunityBrowserInterface::onLine(%this, %line)
{
schedule(500, 0, MessageBoxOK, "ERROR", "Received expired certificate from community server. Is your computer's clock set correctly?");
}
// DarkDragonDX: We seem to have received the community certificate, enable the browser and EMail UI's
for ( %i = 0; %i < LaunchTabView.tabCount(); %i++ )
{
%guiName = LaunchTabView.gui[%i];
if (isObject(%guiName) && (%guiName $="EmailGui" || %guiName $= "TribeandWarriorBrowserGui"))
LaunchTabView.setTabActive(%i, true);
}
// data access methods
@ -1018,4 +1026,5 @@ function tn_community_browser_user_createClan(%tag, %append, %name, %info, %recr
tn_community_browser_processRequest("", %header @ %payload);
}
schedule(3000, 0, tn_community_Browser_request_cert);
// DarkDragonDX: Removed this from being a schedule; it does it when it's ready now
// schedule(3000, 0, tn_community_Browser_request_cert);

View file

@ -256,6 +256,10 @@ function TribeAndWarriorBrowserGui::onWake(%this)
MemberList.Clear();
W_MemberList.clear();
Canvas.pushDialog(LaunchToolbarDlg);
// DarkDragonDX: Set the BUDDYLIST and TRIBES profile
W_BuddyList.setProfile(ShellRedRadioProfile);
W_Tribes.setProfile(ShellRedRadioProfile);
if (TWBTabView.tabCount() == 0)
{
@ -383,13 +387,13 @@ function GuiMLTextCtrl::onURL(%this, %url)
%i = 0;
while((%fld[%i] = getField(%url, %i)) !$= "")
%i++;
%tribe = %fld[1];
%warrior = %fld[2];
switch$(%fld[0])
{
case "player":
LinkBrowser( %fld[1] , "Warrior");
LinkBrowser( %fld[2] , "Warrior");
case "clan": // used to be "tribe" in the Dynamix system -- it is this in TribesNext
LaunchTabView.viewTab("BROWSER", TribeAndWarriorBrowserGui, 0);
TWBTabView.view(%fld[1], "", "Tribe");
@ -1940,4 +1944,47 @@ function CreateTribeProcess()
// send the creation request
tn_community_browser_user_createClan(%tag, %append, %name, %info, %recru);
}
}
// New ShellRadioProfile for TRIBES and BUDDYLIST
new GuiControlProfile(ShellRedRadioProfile) {
tab = "1";
canKeyFocus = "1";
modal = "1";
opaque = "0";
fillColor = "255 0 0 255";
fillColorHL = "255 255 255 255";
fillColorNA = "255 255 255 255";
border = "0";
borderColor = "0 0 0 255";
borderColorHL = "0 0 0 255";
borderColorNA = "0 0 0 255";
fontType = "Univers Condensed";
fontSize = "16";
fontColors[0] = "255 0 0 255";
fontColors[1] = "205 165 0 255";
fontColors[2] = "5 5 5 255";
fontColors[3] = "255 255 255 255";
fontColors[4] = "255 255 255 255";
fontColors[5] = "255 255 255 255";
fontColors[6] = "255 255 255 255";
fontColors[7] = "255 255 255 255";
fontColors[8] = "255 255 255 255";
fontColors[9] = "255 255 255 255";
fontColor = "255 0 0 255";
fontColorHL = "255 0 0 255";
fontColorNA = "5 5 5 255";
fontColorSEL = "255 255 255 255";
justify = "center";
textOffset = "0 0";
autoSizeWidth = "0";
autoSizeHeight = "0";
returnTab = "0";
numbersOnly = "0";
cursorColor = "0 0 0 255";
bitmap = "gui/shll_radio";
soundButtonDown = "sButtonDown";
soundButtonOver = "sButtonOver";
fixedExtent = "1";
};

View file

@ -48,6 +48,13 @@ function CommunitySessionInterface::onLine(%this, %line)
cancel($TribesNext::Community::SessionSchedule);
$TribesNext::Community::SessionSchedule = schedule($TribesNext::Community::SessionRefresh * 1000, 0, tn_community_login_initiate);
// DarkDragonDX: Got a UUID, try for a community certificate
exec("t2csri/community/mail.cs");
exec("t2csri/community/browser.cs");
exec("t2csri/community/mailUI.cs");
exec("t2csri/community/browserUI.cs");
tn_community_Browser_request_cert();
}
else if (getSubStr(%line, 0, 5) $= "ERR: ")
{
@ -182,4 +189,4 @@ function tn_community_login_initiate()
}
CommunitySessionInterface.data = %payload;
CommunitySessionInterface.connect($TribesNext::Community::Host @ ":" @ $TribesNext::Community::Port);
}
}

View file

@ -51,6 +51,8 @@ function CommunityMailInterface::onLine(%this, %line)
if (trim(%line) $= "")
{
%this.primed = 1;
tn_community_mail_requestCompleted();
return;
}
if (!%this.primed)
@ -414,6 +416,9 @@ function tn_community_mail_request_send(%subject, %contents, %to, %cc)
%payload = %payload @ "--" @ %boundary @ %rand @ "\r\n";
// cc
if (trim(%cc) $= "")
%cc = 0; // DarkDragonDX: No CC?
%payload = %payload @ %formelem @ "cc\"\r\n\r\n" @ %cc @ "\r\n";
%payload = %payload @ "--" @ %boundary @ %rand @ "\r\n";
@ -447,3 +452,32 @@ function tn_community_isUserBlocked(%searchguid)
{
return tn_community_isOnList(%searchguid, "ignore");
}
// DarkDragonDX: Hookable script callback for when a request with the mail system completes
function tn_community_mail_requestCompleted(){ }
// DarkDragonDX: Helpers function to work with the JSON (somewhat)
function tn_community_mail_explodeJSONObject(%json)
{
%json = trim(%json);
%json = stripChars(%json, "{}\"'");
// The EMail contents of a tribal invite shouldn't contain spaces so this should be safe
%json = strReplace(%json, ",", " ");
return %json;
}
// %processed should have been processed with tn_community_mail_explodeJSONObject
function tn_community_mail_getJSONElement(%processed, %element)
{
%element = strlwr(%element);
for (%i = 0; %i < getWordCount(%processed); %i++)
{
%word = strReplace(getWord(%processed, %i), ":", " ");
if (strlwr(getWord(%word, 0)) $= %element)
return getWord(%word, 1);
}
return -1;
}

View file

@ -376,14 +376,29 @@ function EmailGetTextDisplay(%text)
%to = getLinkNameList(%toList);
%ccList = getRecord(%text, 5);
%ccLine = getLinkNameList(%ccList);
// DarkDragonDX: Check if it's a tribal invite
%subjectLine = getRecord(%text, 6);
%emailContents = EmailGetBody(%text);
%senderName = getLinkName(getRecord(%text, 1), 0);
if (getWords(%subjectLine, 0, 1) $= "Invitation to:")
{
%emailContents = tn_community_mail_explodeJSONObject(%emailContents);
%clanID = tn_community_mail_getJSONElement(%emailContents, "clanid");
%expiration = tn_community_mail_getJSONElement(%emailContents, "expire");
%emailContents = %senderName SPC "of clan \"" @ trim(getWords(%subjectLine, 2)) @ "\" has invited you to join their clan." NL
"<a:acceptinvite-" @ %clanID @ ">Accept</a> or <a:rejectinvite-" @ %clanID @ ">Reject</a> the invitation? This invitation expires at <spush><color:ADFFFA>" @ tn_community_mailui_epochToDate(%expiration) @ "<spop>.";
}
%from = getLinkName(getRecord(%text, 1), 0);
%from = %senderName;
%msgtext = "From: " @ %from NL
"To: " @ %to NL
"CC: " @ %ccLine NL
"Subject: " @ getRecord(%text, 6) NL
"Subject: " @ %subjectLine NL
"Date Sent: " @ getRecord(%text, 3) @ "\n\n" @
EmailGetBody(%text);
%emailContents;
return %prepend @ %msgtext;
}
@ -624,23 +639,6 @@ function DoEmailDelete(%mid, %state)
tn_community_mailui_clearCheckStatus();
}
// replacing function in webemail.cs, 1017
function EmailGui::ButtonClick(%this,%ord)
{
switch(%ord)
{
case 0: // wired to inbox button
$TribesNext::Community::MailUI::ActiveMailbox = "inbox";
tn_community_mailui_clearCheckStatus();
case 1: // wired to deleted items button
$TribesNext::Community::MailUI::ActiveMailbox = "deleted";
tn_community_mailui_clearCheckStatus();
case 2: // newly wired to sent items button which was present, but hidden
$TribesNext::Community::MailUI::ActiveMailbox = "sentbox";
tn_community_mailui_clearCheckStatus();
}
}
// replacing function in webemail.cs, 1229
function EmailGui::loadCache(%this) { }
// replacing function in webemail.cs, 1274
@ -931,6 +929,25 @@ function AddressDlg::onWake(%this)
}
}
function tn_community_mailui_selectedBox(%box)
{
switch (%box)
{
case 0: // wired to inbox button
$TribesNext::Community::MailUI::ActiveMailbox = "inbox";
tn_community_mailui_clearCheckStatus();
tn_community_mailui_displayBox("inbox");
case 1: // wired to deleted items button
$TribesNext::Community::MailUI::ActiveMailbox = "deleted";
tn_community_mailui_clearCheckStatus();
tn_community_mailui_displayBox("deleted");
case 2: // newly wired to sent items button which was present, but hidden
$TribesNext::Community::MailUI::ActiveMailbox = "sentbox";
tn_community_mailui_clearCheckStatus();
tn_community_mailui_displayBox("sentbox");
}
}
package tn_tmail
{
function EmailGui::onWake(%this)
@ -945,6 +962,11 @@ package tn_tmail
EM_BlockBtn.setActive( false );
%selId = EM_Browser.getSelectedId();
Canvas.pushDialog(LaunchToolbarDlg);
// DarkDragonDX: The mailUI override for selected buttons didn't work
rbInbox.command = "tn_community_mailui_selectedBox(0);";
rbSendItems.command = "tn_community_mailui_selectedBox(2);";
rbDeleted.command = "tn_community_mailui_selectedBox(1);";
if ( EM_Browser.rowCount() > 0 )
{
@ -966,6 +988,46 @@ package tn_tmail
$TribesNext::Community::MailUI::Awake = 0;
//error("EmailGui::onSleep: " @ %this);
}
// DarkDragonDX: Overwrite this function for the "GET MAIL" Button
function GetEmailBtnClick()
{
// We request the TMail and when the request completes, the callback
// tn_community_mail_requestCompleted is executed.
tn_community_mail_request_getNew($TribesNext::Community::MailUI::ActiveMailbox);
}
function tn_community_mail_requestCompleted()
{
parent::tn_community_mail_requestCompleted();
// Add a small delay to make sure we have everything
schedule(200,0,"tn_community_mailui_displayBox", $TribesNext::Community::MailUI::ActiveMailbox);
}
function GuiMLTextCtrl::onURL(%this, %url)
{
%payload = strReplace(%url, "-", " ");
%command = getWord(%payload, 0);
%identifier = getWord(%payload, 1);
switch$(%command)
{
case "acceptinvite":
tn_community_browser_user_acceptInvite(%identifier);
EmailMessageDelete(); // This code shouldn't be executed unless we clicked on accept/reject in an invitations
messageBoxOK("ACCEPTED", "You have accepted the clan invitation.");
case "rejectinvite":
tn_community_browser_user_rejectInvite(%identifier);
EmailMessageDelete();
messageBoxOK("DECLINED", "You have rejected the clan invitation.");
default: // Pass it on to anything else interested
parent::onURL(%this, %url);
}
}
};
if (!isActivePackage(tn_tmail))
activatePackage(tn_tmail);
activatePackage(tn_tmail);

View file

@ -7,7 +7,7 @@
// This file contains the URL and server settings for the community system.
$TribesNext::Community::Host = "localhost";
$TribesNext::Community::Host = "thyth.com";
$TribesNext::Community::Port = 80;
$TribesNext::Community::BaseURL = "/tn/robot/";