Back to index

lightning-sunbird  0.9+nobinonly
Classes | Functions
cal Namespace Reference

Classes

class  UTF8StringEnumerator
class  XpcomBase
 Common base class for XPCOM object implementations: More...

Functions

nsresult createUTF8StringEnumerator (nsAutoPtr< nsCStringArray > &takeOverArray, nsIUTF8StringEnumerator **ppRet)
 Creates a UTF8 string enumerator.
nsresult logError (PRUnichar const *msg)
 Logs an error.
nsresult logWarning (PRUnichar const *msg)
 Logs a warning.
nsresult log (PRUnichar const *msg)
 Just logs.
nsCOMPtr< nsIConsoleService >
const
getConsoleService ()
 Gets the global console service.
nsCOMPtr< calIICSService > constgetICSService ()
 Gets the global ICS service.
nsCOMPtr< calITimezoneService >
const
getTimezoneService ()
 Gets the global timezone service.
nsCOMPtr< calITimezone > constfloating ()
 Gets the "floating" timezone.
nsCOMPtr< calITimezone > constUTC ()
 Gets the "UTC" timezone.
nsCOMPtr< calITimezonedetectTimezone (icaltimetype const &icalt, calITimezoneProvider *tzProvider)
 Detects the timezone icalt refers to, either using the passed timezone provider or the global timezone service.
void logMissingTimezone (char const *tzid)
 Logs a missing timezone into the js console.
icaltimezone * getIcalTimezone (calITimezone *tz)
 Returns the libical VTIMEZONE component, null if floating.
nsresult logError (char const *msg)
nsresult logError (nsACString const &msg)
nsresult logWarning (char const *msg)
nsresult logWarning (nsACString const &msg)
nsresult log (char const *msg)
nsresult log (nsACString const &msg)

Function Documentation

nsresult cal::createUTF8StringEnumerator ( nsAutoPtr< nsCStringArray > &  takeOverArray,
nsIUTF8StringEnumerator **  ppRet 
)

Creates a UTF8 string enumerator.

Parameters:
takeOverArraya nsCStringArray that is taken over by the resulting string enumerator object (nsAutoPtr passes over ownership)
ppRetreturned enumerator object

Definition at line 84 of file calUtils.cpp.

{
    NS_ENSURE_ARG_POINTER(takeOverArray.get());
    NS_ENSURE_ARG_POINTER(ppRet);
    *ppRet = new UTF8StringEnumerator(takeOverArray);
    CAL_ENSURE_MEMORY(*ppRet);
    NS_ADDREF(*ppRet);
    return NS_OK;
}

Here is the call graph for this function:

Detects the timezone icalt refers to, either using the passed timezone provider or the global timezone service.

Parameters:
icaltan icaltime
tzProvidertimezone provider or null which defaults to the timezone service

Definition at line 158 of file calUtils.cpp.

{
    if (!tzProvider) {
        tzProvider = getTimezoneService();
    }
    if (icalt.is_utc) {
        return UTC();
    }
    if (icalt.zone) {
        char const* const tzid = icaltimezone_get_tzid(const_cast<icaltimezone *>(icalt.zone));
        if (tzid) {
            nsCOMPtr<calITimezone> tz;
            tzProvider->GetTimezone(nsDependentCString(tzid), getter_AddRefs(tz));
            if (tz) {
                return tz;
            }
            NS_ASSERTION(tz, "no timezone found, falling back to floating!");
            logMissingTimezone(tzid);
        }
    }
    return floating();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Gets the "floating" timezone.

Definition at line 142 of file calUtils.cpp.

                                         {
    static nsCOMPtr<calITimezone> sFloating;
    if (!sFloating) {
        getTimezoneService()->GetFloating(getter_AddRefs(sFloating));
    }
    return sFloating;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Gets the global console service.

Definition at line 115 of file calUtils.cpp.

                                                       {
    static nsCOMPtr<nsIConsoleService> sObj;
    if (!sObj) {
        sObj = do_GetService("@mozilla.org/consoleservice;1");
        NS_ASSERTION(sObj, "Could not get console service!");
    }
    return sObj;
}

Here is the call graph for this function:

Here is the caller graph for this function:

icaltimezone * cal::getIcalTimezone ( calITimezone tz)

Returns the libical VTIMEZONE component, null if floating.

Attention:
Every timezone provider needs to use calICSService for creating its timezone components since we need to stick to the same libical.

Definition at line 190 of file calUtils.cpp.

                                                  {
    icaltimezone * icaltz = nsnull;
    if (!tz) {
        NS_ASSERTION(false, "No Timezone passed to getIcalTimezone");
        return nsnull;
    }

    PRBool b;
    tz->GetIsUTC(&b);
    if (b) {
        icaltz = icaltimezone_get_utc_timezone();
    } else {
        nsCOMPtr<calIIcalComponent> tzComp;
        tz->GetIcalComponent(getter_AddRefs(tzComp));
        if (tzComp) {
            icaltz = tzComp->GetIcalTimezone();
        } // else floating
    }
    return icaltz;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Gets the global ICS service.

Definition at line 124 of file calUtils.cpp.

                                                {
    static nsCOMPtr<calIICSService> sIcsService;
    if (!sIcsService) {
        sIcsService = do_GetService(CAL_ICSSERVICE_CONTRACTID);
        NS_ASSERTION(sIcsService, "Could not init ics service! Will crash now...");
    }
    return sIcsService;
}

Here is the call graph for this function:

Gets the global timezone service.

Definition at line 133 of file calUtils.cpp.

                                                          {
    static nsCOMPtr<calITimezoneService> sTzService;
    if (!sTzService) {
        sTzService = do_GetService(CAL_TIMEZONESERVICE_CONTRACTID);
        NS_ASSERTION(sTzService, "Could not init timezone service! Will crash now...");
    }
    return sTzService;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult cal::log ( char const msg) [inline]

Definition at line 103 of file calUtils.h.

                                     {
    return log(NS_ConvertASCIItoUTF16(msg).get());
}

Here is the call graph for this function:

nsresult cal::log ( nsACString const msg) [inline]

Definition at line 106 of file calUtils.h.

                                           {
    return log(NS_ConvertASCIItoUTF16(msg).get());
}

Here is the call graph for this function:

Just logs.

Definition at line 111 of file calUtils.cpp.

                                   {
    return getConsoleService()->LogStringMessage(msg);
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult cal::logError ( char const msg) [inline]

Definition at line 81 of file calUtils.h.

                                          {
    return logError(NS_ConvertASCIItoUTF16(msg).get());
}

Here is the call graph for this function:

nsresult cal::logError ( nsACString const msg) [inline]

Definition at line 84 of file calUtils.h.

                                                {
    return logError(NS_ConvertASCIItoUTF16(msg).get());
}

Here is the call graph for this function:

Logs an error.

Definition at line 95 of file calUtils.cpp.

                                        {
    nsresult rc;
    nsCOMPtr<nsIScriptError> const scriptError(do_CreateInstance("@mozilla.org/scripterror;1", &rc));
    NS_ENSURE_SUCCESS(rc, rc);
    rc = scriptError->Init(msg, nsnull, nsnull, 0, 0, nsIScriptError::errorFlag, "calendar");
    return getConsoleService()->LogMessage(scriptError);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Logs a missing timezone into the js console.

Definition at line 182 of file calUtils.cpp.

                                          {
    // xxx todo: needs l10n
    nsString msg(NS_LITERAL_STRING("Timezone \""));
    msg += NS_ConvertUTF8toUTF16(tzid);
    msg += NS_LITERAL_STRING("\" not found, falling back to floating!");
    logError(msg.get());
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult cal::logWarning ( char const msg) [inline]

Definition at line 92 of file calUtils.h.

                                            {
    return logWarning(NS_ConvertASCIItoUTF16(msg).get());
}

Here is the call graph for this function:

nsresult cal::logWarning ( nsACString const msg) [inline]

Definition at line 95 of file calUtils.h.

                                                  {
    return logWarning(NS_ConvertASCIItoUTF16(msg).get());
}

Here is the call graph for this function:

Logs a warning.

Definition at line 103 of file calUtils.cpp.

                                          {
    nsresult rc;
    nsCOMPtr<nsIScriptError> const scriptError(do_CreateInstance("@mozilla.org/scripterror;1", &rc));
    NS_ENSURE_SUCCESS(rc, rc);
    rc = scriptError->Init(msg, nsnull, nsnull, 0, 0, nsIScriptError::warningFlag, "calendar");
    return getConsoleService()->LogMessage(scriptError);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Gets the "UTC" timezone.

Definition at line 150 of file calUtils.cpp.

                                    {
    static nsCOMPtr<calITimezone> sUTC;
    if (!sUTC) {
        getTimezoneService()->GetUTC(getter_AddRefs(sUTC));
    }
    return sUTC;
}

Here is the call graph for this function:

Here is the caller graph for this function: