1 /*
2  * Copyright (C) 2009 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ANDROID_EMOJI_FACTORY_H
18 #define ANDROID_EMOJI_FACTORY_H
19 
20 namespace android {
21 
22 // Abstract class for EmojiFactory.
23 //
24 // Here, PUA (or Android PUA) means Unicode PUA defined for various emoji. The
25 // PUA supports emoji of DoCoMo, KDDI, Softbank and Goomoji. Each PUA defined
26 // by the other vendors (careers) are called Vendor Specific PUA (vsp).
27 // For more information, go
28 // http://unicode.org/~mdavis/08080r-emoji-proposal/ (tentative)
29 class EmojiFactory {
30  public:
~EmojiFactory()31   virtual ~EmojiFactory() {}
32   // Returns binary image data corresponding to "pua". The size of binary is
33   // stored to "size". Returns NULL if there's no mapping from the "pua" to a
34   // specific image. Currently, image format is all (animated) gif.
35   //
36   // TODO(dmiyakawa): there should be a way to tell users the format of the
37   // binary.
38   virtual const char *GetImageBinaryFromAndroidPua(int pua, int *size) = 0;
39 
40   // Returns binary image data corresponding to "sjis", which is defined by
41   // each career. Returns NULL when there's no mapping for "sjis".
GetImageBinaryFromVendorSpecificSjis(unsigned short sjis,int * size)42   virtual const char *GetImageBinaryFromVendorSpecificSjis(unsigned short sjis,
43                                                            int *size) {
44     return GetImageBinaryFromAndroidPua(
45         GetAndroidPuaFromVendorSpecificSjis(sjis), size);
46   }
47 
48   // Returns binary image data corresponding to Vendor-specific PUA "vsp".
49   // Returns NULL when there's no mapping for "vsp".
GetImageBinaryFromVendorSpecificPua(int vsp,int * size)50   virtual const char *GetImageBinaryFromVendorSpecificPua(int vsp,
51                                                           int *size) {
52     return GetImageBinaryFromAndroidPua(
53         GetAndroidPuaFromVendorSpecificPua(vsp), size);
54   }
55 
56   // Returns Android PUA corresponding to "sjis". Returns -1 when there's no
57   // mapping from "sjis" to a Android PUA.
58   virtual int GetAndroidPuaFromVendorSpecificSjis(unsigned short sjis) = 0;
59 
60   // Returns Vendor-specific Shift jis code corresponding to "pua". Returns -1
61   // when ther's no mapping from "pua" to a specific sjis.
62   virtual int GetVendorSpecificSjisFromAndroidPua(int pua) = 0;
63 
64   // Returns maximum Vendor-Specific PUA. This is the last valid value.
65   virtual int GetMaximumVendorSpecificPua() = 0;
66 
67   // Returns minimum Vendor-Specific PUA.
68   virtual int GetMinimumVendorSpecificPua() = 0;
69 
70   // Returns maximum Android PUA. This the last valid value.
71   virtual int GetMaximumAndroidPua() = 0;
72 
73   // Returns minimum Android PUA.
74   virtual int GetMinimumAndroidPua() = 0;
75 
76   // Returns Android PUA corresponding to Vendor-Specific Unicode "vsp". Returns
77   // -1 when there's no mapping from "vsp" to a Android PUA.
78   virtual int GetAndroidPuaFromVendorSpecificPua(int vsp) = 0;
79 
80   // Returns Vendor-specific PUA corresponding to "pua". Returns -1 when
81   // there's no mapping from "pua" to a specific unicode.
82   virtual int GetVendorSpecificPuaFromAndroidPua(int pua) = 0;
83 
84   // Returns non NULL string which defines the name of this factory.
85   // e.g. "docomo", "goomoji"
86   virtual const char *Name() const = 0;
87 
88   // Get a specific implementation of EmojiFactory. If there's no implementation
89   // for "name", returns NULL.
90   // The ownership of the instance remains to this class, so users must not
91   // release it.
92   static EmojiFactory *GetImplementation(const char *name);
93 
94   // Get an implementation of EmojiFactory. This assumes that, usually, there
95   // should be only one possible EmojiFactory implementation. If there are more
96   // than one implementations, most prefered one is returned.
97   // The ownership of the instance remains to this class, so users must not
98   // release it.
99   static EmojiFactory *GetAvailableImplementation();
100 };
101 
102 }  // namespace android
103 
104 #endif // ANDROID_EMOJI_FACTORY_H
105