Ticket #13398: 13398-pospeselr4.patch

File 13398-pospeselr4.patch, 8.0 KB (added by pospeselr, 21 months ago)
  • toolkit/components/startup/nsUserInfoMac.mm

    diff --git a/toolkit/components/startup/nsUserInfoMac.mm b/toolkit/components/startup/nsUserInfoMac.mm
    index 1895cf177353..2a9c260379cb 100644
    a b NS_IMETHODIMP 
    1919nsUserInfo::GetFullname(char16_t **aFullname)
    2020{
    2121  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT
    22  
     22#ifdef ESR59
    2323  NS_ConvertUTF8toUTF16 fullName([NSFullUserName() UTF8String]);
    2424  *aFullname = ToNewUnicode(fullName);
    2525  return NS_OK;
    26  
     26#else
     27  *aFullname = ToNewUnicode(NS_LITERAL_STRING(""));
     28  return *aFullname ? NS_OK : NS_ERROR_FAILURE;
     29#endif
    2730  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT
    2831}
    2932
    30 NS_IMETHODIMP 
     33NS_IMETHODIMP
    3134nsUserInfo::GetUsername(char **aUsername)
    3235{
    3336  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT
    34  
     37#ifdef ESR59
    3538  nsAutoCString username([NSUserName() UTF8String]);
    3639  *aUsername = ToNewCString(username);
    3740  return NS_OK;
    38  
     41#else
     42  *aUsername = ToNewUTF8String(NS_LITERAL_STRING(""));
     43  return *aUsername ? NS_OK : NS_ERROR_FAILURE;
     44#endif
    3945  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT
    4046}
    4147
    42 nsresult 
     48nsresult
    4349nsUserInfo::GetPrimaryEmailAddress(nsCString &aEmailAddress)
    4450{
    4551  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT
    46  
    47   // Try to get this user's primary email from the system addressbook's "me card" 
     52
     53  // Try to get this user's primary email from the system addressbook's "me card"
    4854  // (if they've filled it)
    4955  ABPerson *me = [[ABAddressBook sharedAddressBook] me];
    5056  ABMultiValue *emailAddresses = [me valueForProperty:kABEmailProperty];
    nsUserInfo::GetPrimaryEmailAddress(nsCString &aEmailAddress) 
    5460    aEmailAddress.Assign([[emailAddresses valueAtIndex:primaryEmailIndex] UTF8String]);
    5561    return NS_OK;
    5662  }
    57  
     63
    5864  return NS_ERROR_FAILURE;
    59  
     65
    6066  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT
    6167}
    6268
    63 NS_IMETHODIMP 
     69NS_IMETHODIMP
    6470nsUserInfo::GetEmailAddress(char **aEmailAddress)
    6571{
     72#if ESR59
    6673  nsAutoCString email;
    67   if (NS_SUCCEEDED(GetPrimaryEmailAddress(email))) 
     74  if (NS_SUCCEEDED(GetPrimaryEmailAddress(email)))
    6875    *aEmailAddress = ToNewCString(email);
    6976  return NS_OK;
     77#else
     78  *aEmailAddress = ToNewUTF8String(NS_LITERAL_STRING(""));
     79  return *aEmailAddress ? NS_OK : NS_ERROR_FAILURE;
     80#endif
    7081}
    7182
    72 NS_IMETHODIMP 
     83NS_IMETHODIMP
    7384nsUserInfo::GetDomain(char **aDomain)
    7485{
     86#if ESR59
    7587  nsAutoCString email;
    7688  if (NS_SUCCEEDED(GetPrimaryEmailAddress(email))) {
    7789    int32_t index = email.FindChar('@');
    nsUserInfo::GetDomain(char **aDomain) 
    8193    }
    8294  }
    8395  return NS_OK;
     96#else
     97  *aDomain = ToNewUTF8String(NS_LITERAL_STRING(""));
     98  return *aDomain ? NS_OK : NS_ERROR_FAILURE;
     99#endif
    84100}
  • toolkit/components/startup/nsUserInfoUnix.cpp

    diff --git a/toolkit/components/startup/nsUserInfoUnix.cpp b/toolkit/components/startup/nsUserInfoUnix.cpp
    index 71bc46da2573..4022a15a0b93 100644
    a b NS_IMPL_ISUPPORTS(nsUserInfo,nsIUserInfo) 
    3636NS_IMETHODIMP
    3737nsUserInfo::GetFullname(char16_t **aFullname)
    3838{
     39#ifdef ESR59
    3940    struct passwd *pw = nullptr;
    4041
    4142    pw = getpwuid (geteuid());
    nsUserInfo::GetFullname(char16_t **aFullname) 
    5253    // Full Name, <other stuff> - eliminate the ", <other stuff>
    5354    // also, sometimes GECOS uses "&" to mean "the user name" so do
    5455    // the appropriate substitution
    55    
     56
    5657    // truncate at first comma (field delimiter)
    5758    int32_t index;
    5859    if ((index = fullname.Find(",")) != kNotFound)
    nsUserInfo::GetFullname(char16_t **aFullname) 
    6364        nsAutoCString username(pw->pw_name);
    6465        if (!username.IsEmpty() && nsCRT::IsLower(username.CharAt(0)))
    6566            username.SetCharAt(nsCRT::ToUpper(username.CharAt(0)), 0);
    66            
     67
    6768        fullname.ReplaceSubstring("&", username.get());
    6869    }
    6970
    nsUserInfo::GetFullname(char16_t **aFullname) 
    7677        return NS_OK;
    7778
    7879    return NS_ERROR_FAILURE;
     80#else
     81    *aFullname = ToNewUnicode(NS_LITERAL_STRING(""));
     82    return *aFullname ? NS_OK : NS_ERROR_FAILURE;
     83#endif
    7984}
    8085
    81 NS_IMETHODIMP 
     86NS_IMETHODIMP
    8287nsUserInfo::GetUsername(char * *aUsername)
    8388{
     89#ifdef ESR59
    8490    struct passwd *pw = nullptr;
    8591
    8692    // is this portable?  those are POSIX compliant calls, but I need to check
    nsUserInfo::GetUsername(char * *aUsername) 
    95101    *aUsername = strdup(pw->pw_name);
    96102
    97103    return NS_OK;
     104#else
     105    *aUsername = ToNewUTF8String(NS_LITERAL_STRING(""));
     106    return *aUsername ? NS_OK : NS_ERROR_FAILURE;
     107#endif
    98108}
    99109
    100 NS_IMETHODIMP 
     110NS_IMETHODIMP
    101111nsUserInfo::GetDomain(char * *aDomain)
    102112{
     113#ifdef ESR59
    103114    nsresult rv = NS_ERROR_FAILURE;
    104115
    105116    struct utsname buf;
    106117    char *domainname = nullptr;
    107118
    108     if (uname(&buf) < 0) { 
     119    if (uname(&buf) < 0) {
    109120        return rv;
    110121    }
    111122
    nsUserInfo::GetDomain(char * *aDomain) 
    113124    domainname = buf.domainname;
    114125#endif
    115126
    116     if (domainname && domainname[0]) {   
     127    if (domainname && domainname[0]) {
    117128        *aDomain = strdup(domainname);
    118129        rv = NS_OK;
    119130    }
    nsUserInfo::GetDomain(char * *aDomain) 
    130141            }
    131142        }
    132143    }
    133    
     144
    134145    return rv;
     146#else
     147    *aDomain = ToNewUTF8String(NS_LITERAL_STRING(""));
     148    return *aDomain ? NS_OK : NS_ERROR_FAILURE;
     149#endif
    135150}
    136151
    137 NS_IMETHODIMP 
     152NS_IMETHODIMP
    138153nsUserInfo::GetEmailAddress(char * *aEmailAddress)
    139154{
     155#ifdef ESR59
    140156    // use username + "@" + domain for the email address
    141157
    142158    nsresult rv;
    nsUserInfo::GetEmailAddress(char * *aEmailAddress) 
    161177    }
    162178
    163179    *aEmailAddress = ToNewCString(emailAddress);
    164    
     180
    165181    return NS_OK;
     182#else
     183    *aEmailAddress = ToNewUTF8String(NS_LITERAL_STRING(""));
     184    return *aEmailAddress ? NS_OK : NS_ERROR_FAILURE;
     185#endif
    166186}
    167187
  • toolkit/components/startup/nsUserInfoWin.cpp

    diff --git a/toolkit/components/startup/nsUserInfoWin.cpp b/toolkit/components/startup/nsUserInfoWin.cpp
    index b27a2c483b1c..79ed3d6ef74e 100644
    a b nsUserInfo::GetUsername(char **aUsername) 
    3030{
    3131  NS_ENSURE_ARG_POINTER(aUsername);
    3232  *aUsername = nullptr;
     33#ifdef ESR59
    3334
    3435  // ULEN is the max username length as defined in lmcons.h
    3536  wchar_t username[UNLEN +1];
    nsUserInfo::GetUsername(char **aUsername) 
    3940
    4041  *aUsername = ToNewUTF8String(nsDependentString(username));
    4142  return (*aUsername) ? NS_OK : NS_ERROR_FAILURE;
     43#else
     44  *aUsername = ToNewUTF8String(NS_LITERAL_STRING(""));
     45  return *aUsername ? NS_OK : NS_ERROR_FAILURE;
     46#endif
    4247}
    4348
    4449NS_IMETHODIMP
    nsUserInfo::GetFullname(char16_t **aFullname) 
    4651{
    4752  NS_ENSURE_ARG_POINTER(aFullname);
    4853  *aFullname = nullptr;
     54#ifdef ESR59
    4955
    5056  wchar_t fullName[512];
    5157  DWORD size = mozilla::ArrayLength(fullName);
    nsUserInfo::GetFullname(char16_t **aFullname) 
    9197  }
    9298
    9399  return (*aFullname) ? NS_OK : NS_ERROR_FAILURE;
     100#else
     101  *aFullname = ToNewUnicode(NS_LITERAL_STRING(""));
     102  return *aFullname ? NS_OK : NS_ERROR_FAILURE;
     103#endif
    94104}
    95105
    96106NS_IMETHODIMP
    nsUserInfo::GetDomain(char **aDomain) 
    98108{
    99109  NS_ENSURE_ARG_POINTER(aDomain);
    100110  *aDomain = nullptr;
    101 
     111#ifdef ESR59
    102112  const DWORD level = 100;
    103113  LPBYTE info;
    104114  NET_API_STATUS status = NetWkstaGetInfo(nullptr, level, &info);
    nsUserInfo::GetDomain(char **aDomain) 
    110120  }
    111121
    112122  return (*aDomain) ? NS_OK : NS_ERROR_FAILURE;
     123#else
     124  *aDomain = ToNewUTF8String(NS_LITERAL_STRING(""));
     125  return *aDomain ? NS_OK : NS_ERROR_FAILURE;
     126#endif
    113127}
    114128
    115129NS_IMETHODIMP
    nsUserInfo::GetEmailAddress(char **aEmailAddress) 
    117131{
    118132  NS_ENSURE_ARG_POINTER(aEmailAddress);
    119133  *aEmailAddress = nullptr;
    120 
     134#ifdef ESR59
    121135  // RFC3696 says max length of an email address is 254
    122136  wchar_t emailAddress[255];
    123137  DWORD size = mozilla::ArrayLength(emailAddress);
    nsUserInfo::GetEmailAddress(char **aEmailAddress) 
    130144
    131145  *aEmailAddress = ToNewUTF8String(nsDependentString(emailAddress));
    132146  return (*aEmailAddress) ? NS_OK : NS_ERROR_FAILURE;
     147#else
     148  *aEmailAddress = ToNewUTF8String(NS_LITERAL_STRING(""));
     149  return *aEmailAddress ? NS_OK : NS_ERROR_FAILURE;
     150#endif
    133151}