mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
8c296bbcd4
This patch was generated by a script. Here's the source of the script for future reference: function convert() { echo "Converting $1 to $2..." find . ! -wholename "*nsprpub*" \ ! -wholename "*security/nss*" \ ! -wholename "*/.hg*" \ ! -wholename "obj-ff-dbg*" \ ! -name nsXPCOMCID.h \ ! -name prtypes.h \ -type f \ \( -iname "*.cpp" \ -o -iname "*.h" \ -o -iname "*.c" \ -o -iname "*.cc" \ -o -iname "*.idl" \ -o -iname "*.ipdl" \ -o -iname "*.ipdlh" \ -o -iname "*.mm" \) | \ xargs -n 1 sed -i -e "s/\b$1\b/$2/g" } convert PRInt8 int8_t convert PRUint8 uint8_t convert PRInt16 int16_t convert PRUint16 uint16_t convert PRInt32 int32_t convert PRUint32 uint32_t convert PRInt64 int64_t convert PRUint64 uint64_t convert PRIntn int convert PRUintn unsigned convert PRSize size_t convert PROffset32 int32_t convert PROffset64 int64_t convert PRPtrdiff ptrdiff_t convert PRFloat64 double
137 lines
3.8 KiB
C++
137 lines
3.8 KiB
C++
/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "nsFilePicker.h"
|
|
#include "AndroidBridge.h"
|
|
#include "nsNetUtil.h"
|
|
#include "nsIURI.h"
|
|
|
|
NS_IMPL_ISUPPORTS1(nsFilePicker, nsIFilePicker)
|
|
|
|
NS_IMETHODIMP nsFilePicker::Init(nsIDOMWindow *parent, const nsAString& title,
|
|
int16_t mode)
|
|
{
|
|
return (mode == nsIFilePicker::modeOpen ||
|
|
mode == nsIFilePicker::modeOpenMultiple)
|
|
? NS_OK
|
|
: NS_ERROR_NOT_IMPLEMENTED;
|
|
}
|
|
|
|
NS_IMETHODIMP nsFilePicker::AppendFilters(int32_t aFilterMask)
|
|
{
|
|
if (aFilterMask == (filterAudio | filterAll)) {
|
|
mMimeTypeFilter.AssignLiteral("audio/*");
|
|
return NS_OK;
|
|
}
|
|
|
|
if (aFilterMask == (filterImages | filterAll)) {
|
|
mMimeTypeFilter.AssignLiteral("image/*");
|
|
return NS_OK;
|
|
}
|
|
|
|
if (aFilterMask == (filterVideo | filterAll)) {
|
|
mMimeTypeFilter.AssignLiteral("video/*");
|
|
return NS_OK;
|
|
}
|
|
|
|
if (aFilterMask & filterAll) {
|
|
mMimeTypeFilter.AssignLiteral("*/*");
|
|
return NS_OK;
|
|
}
|
|
|
|
return nsBaseFilePicker::AppendFilters(aFilterMask);
|
|
}
|
|
|
|
NS_IMETHODIMP nsFilePicker::AppendFilter(const nsAString& /*title*/,
|
|
const nsAString& filter)
|
|
{
|
|
if (!mExtensionsFilter.IsEmpty())
|
|
mExtensionsFilter.AppendLiteral(", ");
|
|
mExtensionsFilter.Append(filter);
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP nsFilePicker::GetDefaultString(nsAString & aDefaultString)
|
|
{
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
}
|
|
NS_IMETHODIMP nsFilePicker::SetDefaultString(const nsAString & aDefaultString)
|
|
{
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
}
|
|
|
|
NS_IMETHODIMP nsFilePicker::GetDefaultExtension(nsAString & aDefaultExtension)
|
|
{
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
}
|
|
NS_IMETHODIMP nsFilePicker::SetDefaultExtension(const nsAString & aDefaultExtension)
|
|
{
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
}
|
|
|
|
NS_IMETHODIMP nsFilePicker::GetDisplayDirectory(nsIFile **aDisplayDirectory)
|
|
{
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
}
|
|
NS_IMETHODIMP nsFilePicker::SetDisplayDirectory(nsIFile *aDisplayDirectory)
|
|
{
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
}
|
|
|
|
NS_IMETHODIMP nsFilePicker::GetFile(nsIFile **aFile)
|
|
{
|
|
NS_ENSURE_ARG_POINTER(aFile);
|
|
|
|
*aFile = nullptr;
|
|
if (mFilePath.IsEmpty()) {
|
|
return NS_OK;
|
|
}
|
|
|
|
nsCOMPtr<nsIFile> file(do_CreateInstance("@mozilla.org/file/local;1"));
|
|
NS_ENSURE_TRUE(file, NS_ERROR_FAILURE);
|
|
|
|
file->InitWithPath(mFilePath);
|
|
|
|
NS_ADDREF(*aFile = file);
|
|
|
|
nsCString path;
|
|
(*aFile)->GetNativePath(path);
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP nsFilePicker::GetFileURL(nsIURI **aFileURL)
|
|
{
|
|
nsCOMPtr<nsIFile> file;
|
|
GetFile(getter_AddRefs(file));
|
|
|
|
nsCOMPtr<nsIURI> uri;
|
|
NS_NewFileURI(getter_AddRefs(uri), file);
|
|
NS_ENSURE_TRUE(uri, NS_ERROR_FAILURE);
|
|
|
|
return CallQueryInterface(uri, aFileURL);
|
|
}
|
|
|
|
NS_IMETHODIMP nsFilePicker::Show(int16_t *_retval)
|
|
{
|
|
if (!mozilla::AndroidBridge::Bridge())
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
nsAutoString filePath;
|
|
|
|
if (mExtensionsFilter.IsEmpty() == mMimeTypeFilter.IsEmpty()) {
|
|
// Both filters or none of them are set. We want to show anything we can.
|
|
mozilla::AndroidBridge::Bridge()->ShowFilePickerForMimeType(filePath, NS_LITERAL_STRING("*/*"));
|
|
} else if (!mExtensionsFilter.IsEmpty()) {
|
|
mozilla::AndroidBridge::Bridge()->ShowFilePickerForExtensions(filePath, mExtensionsFilter);
|
|
} else {
|
|
mozilla::AndroidBridge::Bridge()->ShowFilePickerForMimeType(filePath, mMimeTypeFilter);
|
|
}
|
|
|
|
*_retval = EmptyString().Equals(filePath) ?
|
|
nsIFilePicker::returnCancel : nsIFilePicker::returnOK;
|
|
if (*_retval == nsIFilePicker::returnOK)
|
|
mFilePath.Assign(filePath);
|
|
return NS_OK;
|
|
}
|