1/**
2 * All rights reserved. Licensed under the Apache License, Version 2.0 (the "License");
3 * you may not use this file except in compliance with the License.
4 * You may obtain a copy of the License at
5 *
6 *     http://www.apache.org/licenses/LICENSE-2.0
7 *
8 * Unless required by applicable law or agreed to in writing, software
9 * distributed under the License is distributed on an "AS IS" BASIS,
10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 * See the License for the specific language governing permissions and
12 * limitations under the License.
13 */
14
15package org.jivesoftware.smackx;
16
17import org.jivesoftware.smack.provider.PrivacyProvider;
18import org.jivesoftware.smack.provider.ProviderManager;
19import org.jivesoftware.smackx.GroupChatInvitation;
20import org.jivesoftware.smackx.PrivateDataManager;
21import org.jivesoftware.smackx.bytestreams.ibb.provider.CloseIQProvider;
22import org.jivesoftware.smackx.bytestreams.ibb.provider.DataPacketProvider;
23import org.jivesoftware.smackx.bytestreams.ibb.provider.OpenIQProvider;
24import org.jivesoftware.smackx.bytestreams.socks5.provider.BytestreamsProvider;
25import org.jivesoftware.smackx.carbons.Carbon;
26import org.jivesoftware.smackx.entitycaps.provider.CapsExtensionProvider;
27import org.jivesoftware.smackx.forward.Forwarded;
28import org.jivesoftware.smackx.packet.AttentionExtension;
29import org.jivesoftware.smackx.packet.ChatStateExtension;
30import org.jivesoftware.smackx.packet.LastActivity;
31import org.jivesoftware.smackx.packet.Nick;
32import org.jivesoftware.smackx.packet.OfflineMessageInfo;
33import org.jivesoftware.smackx.packet.OfflineMessageRequest;
34import org.jivesoftware.smackx.packet.SharedGroupsInfo;
35import org.jivesoftware.smackx.ping.provider.PingProvider;
36import org.jivesoftware.smackx.provider.DataFormProvider;
37import org.jivesoftware.smackx.provider.DelayInformationProvider;
38import org.jivesoftware.smackx.provider.DiscoverInfoProvider;
39import org.jivesoftware.smackx.provider.DiscoverItemsProvider;
40import org.jivesoftware.smackx.provider.HeadersProvider;
41import org.jivesoftware.smackx.provider.HeaderProvider;
42import org.jivesoftware.smackx.provider.MUCAdminProvider;
43import org.jivesoftware.smackx.provider.MUCOwnerProvider;
44import org.jivesoftware.smackx.provider.MUCUserProvider;
45import org.jivesoftware.smackx.provider.MessageEventProvider;
46import org.jivesoftware.smackx.provider.MultipleAddressesProvider;
47import org.jivesoftware.smackx.provider.RosterExchangeProvider;
48import org.jivesoftware.smackx.provider.StreamInitiationProvider;
49import org.jivesoftware.smackx.provider.VCardProvider;
50import org.jivesoftware.smackx.provider.XHTMLExtensionProvider;
51import org.jivesoftware.smackx.pubsub.provider.AffiliationProvider;
52import org.jivesoftware.smackx.pubsub.provider.AffiliationsProvider;
53import org.jivesoftware.smackx.pubsub.provider.ConfigEventProvider;
54import org.jivesoftware.smackx.pubsub.provider.EventProvider;
55import org.jivesoftware.smackx.pubsub.provider.FormNodeProvider;
56import org.jivesoftware.smackx.pubsub.provider.ItemProvider;
57import org.jivesoftware.smackx.pubsub.provider.ItemsProvider;
58import org.jivesoftware.smackx.pubsub.provider.PubSubProvider;
59import org.jivesoftware.smackx.pubsub.provider.RetractEventProvider;
60import org.jivesoftware.smackx.pubsub.provider.SimpleNodeProvider;
61import org.jivesoftware.smackx.pubsub.provider.SubscriptionProvider;
62import org.jivesoftware.smackx.pubsub.provider.SubscriptionsProvider;
63import org.jivesoftware.smackx.receipts.DeliveryReceipt;
64import org.jivesoftware.smackx.search.UserSearch;
65
66/**
67 * Since dalvik on Android does not allow the loading of META-INF files from the
68 * filesystem, you have to register every provider manually.
69 *
70 * The full list of providers is at:
71 * http://fisheye.igniterealtime.org/browse/smack/trunk/build/resources/META-INF/smack.providers?hb=true
72 *
73 * @author Florian Schmaus fschmaus@gmail.com
74 *
75 */
76public class ConfigureProviderManager {
77
78    public static void configureProviderManager() {
79        ProviderManager pm = ProviderManager.getInstance();
80
81        // The order is the same as in the smack.providers file
82
83        //  Private Data Storage
84        pm.addIQProvider("query","jabber:iq:private", new PrivateDataManager.PrivateDataIQProvider());
85        //  Time
86        try {
87            pm.addIQProvider("query","jabber:iq:time", Class.forName("org.jivesoftware.smackx.packet.Time"));
88        } catch (ClassNotFoundException e) {
89            System.err.println("Can't load class for org.jivesoftware.smackx.packet.Time");
90        }
91
92        //  Roster Exchange
93        pm.addExtensionProvider("x","jabber:x:roster", new RosterExchangeProvider());
94        //  Message Events
95        pm.addExtensionProvider("x","jabber:x:event", new MessageEventProvider());
96        //  Chat State
97        pm.addExtensionProvider("active","http://jabber.org/protocol/chatstates", new ChatStateExtension.Provider());
98        pm.addExtensionProvider("composing","http://jabber.org/protocol/chatstates", new ChatStateExtension.Provider());
99        pm.addExtensionProvider("paused","http://jabber.org/protocol/chatstates", new ChatStateExtension.Provider());
100        pm.addExtensionProvider("inactive","http://jabber.org/protocol/chatstates", new ChatStateExtension.Provider());
101        pm.addExtensionProvider("gone","http://jabber.org/protocol/chatstates", new ChatStateExtension.Provider());
102
103        //  XHTML
104        pm.addExtensionProvider("html","http://jabber.org/protocol/xhtml-im", new XHTMLExtensionProvider());
105
106        //  Group Chat Invitations
107        pm.addExtensionProvider("x","jabber:x:conference", new GroupChatInvitation.Provider());
108        //  Service Discovery # Items
109        pm.addIQProvider("query","http://jabber.org/protocol/disco#items", new DiscoverItemsProvider());
110        //  Service Discovery # Info
111        pm.addIQProvider("query","http://jabber.org/protocol/disco#info", new DiscoverInfoProvider());
112        //  Data Forms
113        pm.addExtensionProvider("x","jabber:x:data", new DataFormProvider());
114        //  MUC User
115        pm.addExtensionProvider("x","http://jabber.org/protocol/muc#user", new MUCUserProvider());
116        //  MUC Admin
117        pm.addIQProvider("query","http://jabber.org/protocol/muc#admin", new MUCAdminProvider());
118        //  MUC Owner
119        pm.addIQProvider("query","http://jabber.org/protocol/muc#owner", new MUCOwnerProvider());
120        //  Delayed Delivery
121        pm.addExtensionProvider("x","jabber:x:delay", new DelayInformationProvider());
122        pm.addExtensionProvider("delay", "urn:xmpp:delay", new DelayInformationProvider());
123        //  Version
124        try {
125            pm.addIQProvider("query","jabber:iq:version", Class.forName("org.jivesoftware.smackx.packet.Version"));
126        } catch (ClassNotFoundException e) {
127            System.err.println("Can't load class for org.jivesoftware.smackx.packet.Version");
128        }
129        //  VCard
130        pm.addIQProvider("vCard","vcard-temp", new VCardProvider());
131        //  Offline Message Requests
132        pm.addIQProvider("offline","http://jabber.org/protocol/offline", new OfflineMessageRequest.Provider());
133        //  Offline Message Indicator
134        pm.addExtensionProvider("offline","http://jabber.org/protocol/offline", new OfflineMessageInfo.Provider());
135        //  Last Activity
136        pm.addIQProvider("query","jabber:iq:last", new LastActivity.Provider());
137        //  User Search
138        pm.addIQProvider("query","jabber:iq:search", new UserSearch.Provider());
139        //  SharedGroupsInfo
140        pm.addIQProvider("sharedgroup","http://www.jivesoftware.org/protocol/sharedgroup", new SharedGroupsInfo.Provider());
141
142        //  JEP-33: Extended Stanza Addressing
143        pm.addExtensionProvider("addresses","http://jabber.org/protocol/address", new MultipleAddressesProvider());
144
145        //   FileTransfer
146        pm.addIQProvider("si","http://jabber.org/protocol/si", new StreamInitiationProvider());
147        pm.addIQProvider("query","http://jabber.org/protocol/bytestreams", new BytestreamsProvider());
148        pm.addIQProvider("open","http://jabber.org/protocol/ibb", new OpenIQProvider());
149        pm.addIQProvider("data","http://jabber.org/protocol/ibb", new DataPacketProvider());
150        pm.addIQProvider("close","http://jabber.org/protocol/ibb", new CloseIQProvider());
151        pm.addExtensionProvider("data","http://jabber.org/protocol/ibb", new DataPacketProvider());
152
153        //  Privacy
154        pm.addIQProvider("query","jabber:iq:privacy", new PrivacyProvider());
155
156        // SHIM
157        pm.addExtensionProvider("headers", "http://jabber.org/protocol/shim", new HeadersProvider());
158        pm.addExtensionProvider("header", "http://jabber.org/protocol/shim", new HeaderProvider());
159
160        // PubSub
161        pm.addIQProvider("pubsub", "http://jabber.org/protocol/pubsub", new PubSubProvider());
162        pm.addExtensionProvider("create", "http://jabber.org/protocol/pubsub", new SimpleNodeProvider());
163        pm.addExtensionProvider("items", "http://jabber.org/protocol/pubsub", new ItemsProvider());
164        pm.addExtensionProvider("item", "http://jabber.org/protocol/pubsub", new ItemProvider());
165        pm.addExtensionProvider("subscriptions", "http://jabber.org/protocol/pubsub", new SubscriptionsProvider());
166        pm.addExtensionProvider("subscription", "http://jabber.org/protocol/pubsub", new SubscriptionProvider());
167        pm.addExtensionProvider("affiliations", "http://jabber.org/protocol/pubsub", new AffiliationsProvider());
168        pm.addExtensionProvider("affiliation", "http://jabber.org/protocol/pubsub", new AffiliationProvider());
169        pm.addExtensionProvider("options", "http://jabber.org/protocol/pubsub", new FormNodeProvider());
170        // PubSub owner
171        pm.addIQProvider("pubsub", "http://jabber.org/protocol/pubsub#owner", new PubSubProvider());
172        pm.addExtensionProvider("configure", "http://jabber.org/protocol/pubsub#owner", new FormNodeProvider());
173        pm.addExtensionProvider("default", "http://jabber.org/protocol/pubsub#owner", new FormNodeProvider());
174        // PubSub event
175        pm.addExtensionProvider("event", "http://jabber.org/protocol/pubsub#event", new EventProvider());
176        pm.addExtensionProvider("configuration", "http://jabber.org/protocol/pubsub#event", new ConfigEventProvider());
177        pm.addExtensionProvider("delete", "http://jabber.org/protocol/pubsub#event", new SimpleNodeProvider());
178        pm.addExtensionProvider("options", "http://jabber.org/protocol/pubsub#event", new FormNodeProvider());
179        pm.addExtensionProvider("items", "http://jabber.org/protocol/pubsub#event", new ItemsProvider());
180        pm.addExtensionProvider("item", "http://jabber.org/protocol/pubsub#event", new ItemProvider());
181        pm.addExtensionProvider("retract", "http://jabber.org/protocol/pubsub#event", new RetractEventProvider());
182        pm.addExtensionProvider("purge", "http://jabber.org/protocol/pubsub#event", new SimpleNodeProvider());
183
184        // Nick Exchange
185        pm.addExtensionProvider("nick", "http://jabber.org/protocol/nick", new Nick.Provider());
186
187        // Attention
188        pm.addExtensionProvider("attention", "urn:xmpp:attention:0", new AttentionExtension.Provider());
189
190	// XEP-0297 Stanza Forwarding
191	pm.addExtensionProvider("forwarded", "urn:xmpp:forward:0", new Forwarded.Provider());
192
193	// XEP-0280 Message Carbons
194	pm.addExtensionProvider("sent", "urn:xmpp:carbons:2", new Carbon.Provider());
195	pm.addExtensionProvider("received", "urn:xmpp:carbons:2", new Carbon.Provider());
196
197	// XEP-0199 XMPP Ping
198	pm.addIQProvider("ping", "urn:xmpp:ping", new PingProvider());
199
200	// XEP-184 Message Delivery Receipts
201	pm.addExtensionProvider("received", "urn:xmpp:receipts", new DeliveryReceipt.Provider());
202	pm.addExtensionProvider("request", "urn:xmpp:receipts", new DeliveryReceipt.Provider());
203
204	// XEP-0115 Entity Capabilities
205	pm.addExtensionProvider("c", "http://jabber.org/protocol/caps", new CapsExtensionProvider());
206    }
207}
208