Manually merge of MAINT-8203 Group notices processing

Wed, 04 Apr 2018 20:57:01 +0200

author
Ansariel
date
Wed, 04 Apr 2018 20:57:01 +0200
changeset 55028
b2efb57148e2
parent 55027
3d83e98f3ac8
child 55029
36d269b6a858

Manually merge of MAINT-8203 Group notices processing

indra/newview/llimprocessing.cpp file | annotate | diff | revisions
indra/newview/llimprocessing.h file | annotate | diff | revisions
     1.1 --- a/indra/newview/llimprocessing.cpp	Wed Apr 04 17:30:24 2018 +0200
     1.2 +++ b/indra/newview/llimprocessing.cpp	Wed Apr 04 20:57:01 2018 +0200
     1.3 @@ -45,6 +45,7 @@
     1.4  #include "llnotificationmanager.h"
     1.5  #include "llpanelgroup.h"
     1.6  #include "llregionhandle.h"
     1.7 +#include "llsdserialize.h"
     1.8  #include "llslurl.h"
     1.9  #include "llstring.h"
    1.10  #include "lltoastnotifypanel.h"
    1.11 @@ -622,7 +623,8 @@
    1.12      LLVector3 position,
    1.13      U8 *binary_bucket,
    1.14      S32 binary_bucket_size,
    1.15 -    LLHost &sender)
    1.16 +    LLHost &sender,
    1.17 +    LLUUID aux_id)
    1.18  {
    1.19      LLChat chat;
    1.20      std::string buffer;
    1.21 @@ -1067,58 +1069,81 @@
    1.22      case IM_GROUP_NOTICE_REQUESTED:
    1.23          {
    1.24              LL_INFOS("Messaging") << "Received IM_GROUP_NOTICE message." << LL_ENDL;
    1.25 -            // Read the binary bucket for more information.
    1.26 -            struct notice_bucket_header_t
    1.27 +
    1.28 +            LLUUID agent_id = from_id;
    1.29 +            U8 has_inventory;
    1.30 +            U8 asset_type = 0;
    1.31 +            LLUUID group_id;
    1.32 +            std::string item_name;
    1.33 +
    1.34 +            if (aux_id.notNull())
    1.35              {
    1.36 -                U8 has_inventory;
    1.37 -                U8 asset_type;
    1.38 -                LLUUID group_id;
    1.39 -            };
    1.40 -            struct notice_bucket_full_t
    1.41 +                // aux_id contains group id, binary bucket contains name and asset type
    1.42 +                group_id = aux_id;
    1.43 +                has_inventory = binary_bucket_size > 1 ? TRUE : FALSE;
    1.44 +                from_group = TRUE; // inaccurate value correction
    1.45 +                if (has_inventory)
    1.46 +                {
    1.47 +                    std::string str_bucket = ll_safe_string((char*)binary_bucket, binary_bucket_size);
    1.48 +
    1.49 +                    typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
    1.50 +                    boost::char_separator<char> sep("|", "", boost::keep_empty_tokens);
    1.51 +                    tokenizer tokens(str_bucket, sep);
    1.52 +                    tokenizer::iterator iter = tokens.begin();
    1.53 +
    1.54 +                    asset_type = (LLAssetType::EType)(atoi((*(iter++)).c_str()));
    1.55 +                    iter++; // wearable type if applicable, otherwise asset type
    1.56 +                    item_name = std::string((*(iter++)).c_str());
    1.57 +                    // Note There is more elements in 'tokens' ...
    1.58 +
    1.59 +
    1.60 +                    for (int i = 0; i < 6; i++)
    1.61 +                    {
    1.62 +                        LL_WARNS() << *(iter++) << LL_ENDL;
    1.63 +                        iter++;
    1.64 +                    }
    1.65 +                }
    1.66 +            }
    1.67 +            else
    1.68              {
    1.69 -                struct notice_bucket_header_t header;
    1.70 -                U8 item_name[DB_INV_ITEM_NAME_BUF_SIZE];
    1.71 -            }* notice_bin_bucket;
    1.72 +                // All info is in binary bucket, read it for more information.
    1.73 +                struct notice_bucket_header_t
    1.74 +                {
    1.75 +                    U8 has_inventory;
    1.76 +                    U8 asset_type;
    1.77 +                    LLUUID group_id;
    1.78 +                };
    1.79 +                struct notice_bucket_full_t
    1.80 +                {
    1.81 +                    struct notice_bucket_header_t header;
    1.82 +                    U8 item_name[DB_INV_ITEM_NAME_BUF_SIZE];
    1.83 +                }*notice_bin_bucket;
    1.84  
    1.85 -            // Make sure the binary bucket is big enough to hold the header 
    1.86 -            // and a null terminated item name.
    1.87 -            if ( (binary_bucket_size < (S32)((sizeof(notice_bucket_header_t) + sizeof(U8))))
    1.88 -                || (binary_bucket[binary_bucket_size - 1] != '\0') )
    1.89 -            {
    1.90 -                LL_WARNS("Messaging") << "Malformed group notice binary bucket" << LL_ENDL;
    1.91 -                // <FS:Ansariel> Don't flash task icon
    1.92 -                //break;
    1.93 -                return;
    1.94 +                // Make sure the binary bucket is big enough to hold the header 
    1.95 +                // and a null terminated item name.
    1.96 +                if ((binary_bucket_size < (S32)((sizeof(notice_bucket_header_t) + sizeof(U8))))
    1.97 +                    || (binary_bucket[binary_bucket_size - 1] != '\0'))
    1.98 +                {
    1.99 +                    LL_WARNS("Messaging") << "Malformed group notice binary bucket" << LL_ENDL;
   1.100 +                    // <FS:Ansariel> Don't flash task icon
   1.101 +                    //break;
   1.102 +                    return;
   1.103 +                }
   1.104 +
   1.105 +                notice_bin_bucket = (struct notice_bucket_full_t*) &binary_bucket[0];
   1.106 +                has_inventory = notice_bin_bucket->header.has_inventory;
   1.107 +                asset_type = notice_bin_bucket->header.asset_type;
   1.108 +                group_id = notice_bin_bucket->header.group_id;
   1.109 +                item_name = ll_safe_string((const char*)notice_bin_bucket->item_name);
   1.110              }
   1.111  
   1.112 -            // The group notice packet does not have an AgentID.  Obtain one from the name cache.
   1.113 -            // If last name is "Resident" strip it out so the cache name lookup works.
   1.114 -            std::string::size_type index = original_name.find(" Resident");
   1.115 -            if (index != std::string::npos)
   1.116 -            {
   1.117 -                original_name = original_name.substr(0, index);
   1.118 -            }
   1.119 -
   1.120 -            std::string legacy_name = gCacheName->buildLegacyName(original_name);
   1.121 -            LLUUID agent_id = LLAvatarNameCache::findIdByName(legacy_name);
   1.122 -
   1.123 -            if (agent_id.isNull())
   1.124 -            {
   1.125 -                LL_WARNS("Messaging") << "buildLegacyName returned null while processing " << original_name << LL_ENDL;
   1.126 -            }
   1.127 -            else if (LLMuteList::getInstance()->isMuted(agent_id))
   1.128 +            if (agent_id.notNull() && LLMuteList::getInstance()->isMuted(agent_id))
   1.129              {
   1.130                  // <FS:Ansariel> Don't flash task icon
   1.131                  //break;
   1.132                  return;
   1.133              }
   1.134  
   1.135 -            notice_bin_bucket = (struct notice_bucket_full_t*) &binary_bucket[0];
   1.136 -            U8 has_inventory = notice_bin_bucket->header.has_inventory;
   1.137 -            U8 asset_type = notice_bin_bucket->header.asset_type;
   1.138 -            LLUUID group_id = notice_bin_bucket->header.group_id;
   1.139 -            std::string item_name = ll_safe_string((const char*) notice_bin_bucket->item_name);
   1.140 -
   1.141              // If there is inventory, give the user the inventory offer.
   1.142              LLOfferInfo* info = NULL;
   1.143  
   1.144 @@ -2162,9 +2187,10 @@
   1.145      for (; i != iEnd; ++i)
   1.146      {
   1.147          const LLSD &message_data(*i);
   1.148 +
   1.149          LLVector3 position(message_data["local_x"].asReal(), message_data["local_y"].asReal(), message_data["local_z"].asReal());
   1.150          data = message_data["binary_bucket"].asBinary();
   1.151 -        binary_bucket_size = data.size(); // message_data["count"] == data.size() - 1 due to ('\0')
   1.152 +        binary_bucket_size = data.size(); // message_data["count"] always 0
   1.153          U32 parent_estate_id = message_data.has("parent_estate_id") ? message_data["parent_estate_id"].asInteger() : 1; // 1 - IMMainland
   1.154  
   1.155          // Todo: once dirtsim-369 releases, remove one of the int/str options
   1.156 @@ -2183,7 +2209,7 @@
   1.157              message_data["to_agent_id"].asUUID(),
   1.158              IM_OFFLINE,
   1.159              (EInstantMessage)message_data["dialog"].asInteger(),
   1.160 -            message_data["session_id"].asUUID(),
   1.161 +            LLUUID::null, // session id, fix this for friendship offers to work
   1.162              message_data["timestamp"].asInteger(),
   1.163              message_data["from_agent_name"].asString(),
   1.164              message_data["message"].asString(),
   1.165 @@ -2192,7 +2218,8 @@
   1.166              position,
   1.167              &data[0],
   1.168              binary_bucket_size,
   1.169 -            sender);
   1.170 +            sender,
   1.171 +            message_data["asset_id"].asUUID()); // not necessarily an asset
   1.172      }
   1.173  }
   1.174  
     2.1 --- a/indra/newview/llimprocessing.h	Wed Apr 04 17:30:24 2018 +0200
     2.2 +++ b/indra/newview/llimprocessing.h	Wed Apr 04 20:57:01 2018 +0200
     2.3 @@ -47,7 +47,8 @@
     2.4          LLVector3 position,
     2.5          U8 *binary_bucket,
     2.6          S32 binary_bucket_size,
     2.7 -        LLHost &sender);
     2.8 +        LLHost &sender,
     2.9 +        LLUUID aux_id = LLUUID::null);
    2.10  
    2.11      // Either receives list of offline messages from 'ReadOfflineMsgs' capability
    2.12      // or uses legacy method

mercurial