Skip to content

Commit

Permalink
Add PIM classes from phoneME
Browse files Browse the repository at this point in the history
  • Loading branch information
marco-c committed Aug 14, 2014
1 parent 1fddc30 commit 05100ad
Show file tree
Hide file tree
Showing 57 changed files with 11,570 additions and 0 deletions.
32 changes: 32 additions & 0 deletions java/assets/0/en-US.xml
Original file line number Diff line number Diff line change
Expand Up @@ -818,5 +818,37 @@
Value="Loading the application file..."/>
<localized_string Key="AMS_GRA_INTLR_FILE_NOT_FOUND"
Value="File not found in the current path"/>

<localized_string Key="JSR75_ENUM_LISTS"
Value="enumerate lists"/>
<localized_string Key="JSR75_OPEN_DEFAULT_LIST"
Value="open default list"/>
<localized_string Key="JSR75_OPEN_LIST"
Value="open list"/>
<localized_string Key="JSR75_ADD_OR_UPDATE_ITEM"
Value="add or update an item"/>
<localized_string Key="JSR75_REMOVE_ITEM"
Value="remove an item"/>
<localized_string Key="JSR75_ENUM_CATEGORY_ITEMS"
Value="enumerate items in a category"/>
<localized_string Key="JSR75_ENUM_MATCHING_ITEMS"
Value="enumerate matching items"/>
<localized_string Key="JSR75_ENUM_ALL_ITEMS"
Value="enumerate all items"/>
<localized_string Key="JSR75_ENUM_ITEMS_MATCHING_STRING"
Value="enumerate items matching a string"/>
<localized_string Key="JSR75_ADD_CATEGORY"
Value="add a category"/>
<localized_string Key="JSR75_RENAME_CATEGORY"
Value="rename a category"/>
<localized_string Key="JSR75_DELETE_CATEGORY"
Value="delete a category"/>

<localized_string Key="ABSTRACTIONS_PIM_CONTACTS"
Value="PIM contact list"/>
<localized_string Key="ABSTRACTIONS_PIM_EVENTS"
Value="PIM event list"/>
<localized_string Key="ABSTRACTIONS_PIM_TODO"
Value="PIM to-do list"/>
</localized_strings>
</configuration>
131 changes: 131 additions & 0 deletions java/midp/com/sun/j2me/app/AppPackage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
/*
* Copyright 1990-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 only, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License version 2 for more details (a copy is
* included at /legal/license.txt).
*
* You should have received a copy of the GNU General Public License
* version 2 along with this work; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 or visit www.sun.com if you need additional
* information or have any questions.
*/

package com.sun.j2me.app;

import com.sun.j2me.security.Permission;
import com.sun.j2me.security.AccessController;
import com.sun.midp.midlet.MIDletStateHandler;
import com.sun.midp.midletsuite.MIDletSuiteImpl;
import com.sun.midp.midlet.MIDletSuite;
import java.io.InputStream;

/**
* Abstraction for application package
*/
public class AppPackage {

/** Static instance. Only one package can be run in a isolate */
private static AppPackage instance = new AppPackage();

/** Guard from 'new' operator */
private AppPackage() {
}

public static AppPackage getInstance() {
return instance;
}

public int getId() {
return MIDletStateHandler.getMidletStateHandler().
getMIDletSuite().getID();
}


/** Unused ID */
public static final int UNUSED_APP_ID = -1;

/**
* Returns permission status for the specified permission
*
* @param p permission to check
* @return 1 if allowed; 0 if denied; -1 if status is unknown
*/
public int checkPermission(Permission p) {
/*
* IMPL_NOTE: The corresponding method in MIDletSuite used to check
* for permissions silently, i.e. without throwing SecurityException
* or asking user if he allows to proceed.
* This functionality should be added to AccessController; until then,
* it is acceptable to return "unknown", so that security-sensitive
* code will call checkForPermission() anyway.
*/
return -1;
}

/**
* Checks for specified permission status. Throws an exception
* if permission is not allowed. May be blocked to ask user
*
* @param p a permission to check
* @exception SecurityException if permission is not allowed
* @exception InterruptedException if another thread interrupts a calling
* thread while asking user
*/
public void checkForPermission(Permission p) throws InterruptedException {
AccessController.checkPermission(p.getName(), p.getResource(), p.getExtraValue());
}

/**
* Throws an exception if a status for the permission is not allowed
*
* @param p a permission to check
* @exception SecurityException if a status for the permission is not allowed
*/
public void checkIfPermissionAllowed(Permission p) {
if (checkPermission(p) != 1) {
throw new SecurityException();
}
}

/**
* Gets the name of CA that authorized this suite.
*
* @return name of a CA or null if the suite was not signed
*/
public String getCA() {
MIDletSuite ms =
MIDletStateHandler.getMidletStateHandler().getMIDletSuite();

if (ms instanceof com.sun.midp.midletsuite.MIDletSuiteImpl) {
return ((MIDletSuiteImpl)ms).getInstallInfo().getCA();
}
else {
return null;
}
}

/**
* Finds a resource with a given name. This method returns null if no
* resource with this name is found.
*
* @param name name of the desired resource
* @return a <code>java.io.InputStream</code> object.
* @throws NullPointerException if <code>name</code> is <code>null</code>.
*/
public InputStream getResourceAsStream(String name) {
return getClass().getResourceAsStream(name);
}

}
60 changes: 60 additions & 0 deletions java/midp/com/sun/j2me/i18n/Resource.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright 1990-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 only, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License version 2 for more details (a copy is
* included at /legal/license.txt).
*
* You should have received a copy of the GNU General Public License
* version 2 along with this work; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 or visit www.sun.com if you need additional
* information or have any questions.
*/

package com.sun.j2me.i18n;

/**
* Intermediate class for logging facilities
*/
public class Resource extends com.sun.midp.i18n.Resource {
static final int[] months = { ResourceConstants.LCDUI_DF_JAN_SHORT,
ResourceConstants.LCDUI_DF_FEB_SHORT,
ResourceConstants.LCDUI_DF_MAR_SHORT,
ResourceConstants.LCDUI_DF_APR_SHORT,
ResourceConstants.LCDUI_DF_MAY_SHORT,
ResourceConstants.LCDUI_DF_JUN_SHORT,
ResourceConstants.LCDUI_DF_JUL_SHORT,
ResourceConstants.LCDUI_DF_AUG_SHORT,
ResourceConstants.LCDUI_DF_SEP_SHORT,
ResourceConstants.LCDUI_DF_OCT_SHORT,
ResourceConstants.LCDUI_DF_NOV_SHORT,
ResourceConstants.LCDUI_DF_DEC_SHORT };

static final int[] days = { ResourceConstants.LCDUI_DF_SUN,
ResourceConstants.LCDUI_DF_MON,
ResourceConstants.LCDUI_DF_TUE,
ResourceConstants.LCDUI_DF_WED,
ResourceConstants.LCDUI_DF_THU,
ResourceConstants.LCDUI_DF_FRI,
ResourceConstants.LCDUI_DF_SAT };


public static String getMonthName(int key) {
return getString(months[key]);
}

public static String getShortDayName(int key) {
return getString(days[key]);
}
}
27 changes: 27 additions & 0 deletions java/midp/com/sun/j2me/i18n/ResourceConstants.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright 1990-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 only, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License version 2 for more details (a copy is
* included at /legal/license.txt).
*
* You should have received a copy of the GNU General Public License
* version 2 along with this work; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 or visit www.sun.com if you need additional
* information or have any questions.
*/

package com.sun.j2me.i18n;

public class ResourceConstants extends com.sun.midp.i18n.ResourceConstants {}
130 changes: 130 additions & 0 deletions java/midp/com/sun/j2me/jsr75/StringUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
/*
*
*
* Copyright 1990-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 only, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License version 2 for more details (a copy is
* included at /legal/license.txt).
*
* You should have received a copy of the GNU General Public License
* version 2 along with this work; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 or visit www.sun.com if you need additional
* information or have any questions.
*/

package com.sun.j2me.jsr75;

import java.util.Vector;

/**
* Supporting methods for interpreting vCard and vCalendar encodings.
*
*/
public class StringUtil {
/**
* Parses a separated list of strings into a string array.
* An escaped separator (backslash followed by separatorChar) is not
* treated as a separator.
*
* @param data input list to be parsed
* @param separatorChar the character used to separate items
* @param startingPoint Only use the part of the string that
* follows this index
* @param skipFirstIfEmpty whether the first element should be skiped
* if it's empty (data starts with the separator).
* This flag is used to support empty category name
* @return a non-null string array containing string elements
*/
public static String[] split(String data, char separatorChar,
int startingPoint, boolean skipFirstIfEmpty) {
if (startingPoint == data.length()) {
return new String[0];
}

// support for empty tokens:
// if data starts with separator, just skip it
if (skipFirstIfEmpty && data.charAt(startingPoint) == separatorChar) {
startingPoint++;
}

// tokenize elements
Vector elementList = new Vector();
int startSearchAt = startingPoint;
int startOfElement = startingPoint;
for (int i; (i = data.indexOf(separatorChar, startSearchAt)) != -1; ) {
if (i != 0 && data.charAt(i - 1) == '\\') {
// escaped separator. don't treat it as a real separator
startSearchAt = i + 1;
} else {
String element = data.substring(startOfElement, i);
elementList.addElement(element);
startSearchAt = startOfElement = i + 1;
}
}

// there is no separator found
if (elementList.size() == 0) {
return new String[] { data.substring(startOfElement) };
}

// add the last element
elementList.addElement(data.substring(startOfElement));

// convert Vector to array
int size = elementList.size();
String[] elements = new String[size];
for (int i = 0; i < size; i++) {
elements[i] = (String) elementList.elementAt(i);
}

return elements;
}

/**
* Parses a separated list of strings into a string array.
* An escaped separator (backslash followed by separatorChar) is not
* treated as a separator.
*
* @param data input list to be parsed
* @param separatorChar the character used to separate items
* @param startingPoint Only use the part of the string that
* follows this index
* @return a non-null string array containing string elements
*/
public static String[] split(String data, char separatorChar,
int startingPoint) {
return split(data, separatorChar, startingPoint, true);
}

/**
* Joins the elements of a string array together into a single string.
*
* @param elements the string array
* @param separator the string to be included between each pair of
* successive elements
* @return a string containing, alternately, elements of the string array
* and the separator string
*/
public static String join(String[] elements, String separator) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < elements.length; i++) {
if (i > 0) {
sb.append(separator);
}
sb.append(elements[i]);
}
return sb.toString();
}
}
Loading

0 comments on commit 05100ad

Please sign in to comment.