KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sync4j > server > notification > GenericNotificationMessageBuilder


1 /**
2  * Copyright (C) 2003-2005 Funambol
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18 package sync4j.server.notification;
19
20 import sync4j.framework.notification.*;
21
22 /**
23  *
24  * @author Stefano Nichele @ Funambol
25  *
26  * @version $Id: GenericNotificationMessageBuilder.java,v 1.1 2005/05/16 17:32:56 nichele Exp $
27  */

28 public class GenericNotificationMessageBuilder implements NotificationMessageBuilder {
29
30
31     // ---------------------------------------------------------- Public Methods
32

33
34     public byte[] buildMessage(int sessionId, String JavaDoc phoneNumber, String JavaDoc serverId,
35                                String JavaDoc serverPw, byte[] serverNonce, float dmProtocolVersion)
36         throws NotificationException {
37
38         TriggerHeaderNotificationMessage header = new TriggerHeaderNotificationMessage();
39         header.setInitiator(header.INITIATOR_CLIENT);
40         header.setUiMode(header.UI_MODE_NOT_SPECIFIED);
41         header.setVersion(dmProtocolVersion);
42
43         header.setServerIdentifier(serverId);
44
45         header.setSessionId(sessionId);
46
47         DigestNotificationMessage digestMessage = new DigestNotificationMessage();
48         digestMessage.setNonce(serverNonce);
49         digestMessage.setServerId(serverId);
50         digestMessage.setServerPw(serverPw);
51
52         // Uncomment if you want a body message
53
/*
54                  TriggerBodyNotificationMessage bodyMessage = new TriggerBodyNotificationMessage();
55                  byte[] body = {4, 68};
56                  bodyMessage.setBodyMessage(body);
57          */

58
59         TriggerNotificationMessage notificationMsg = new TriggerNotificationMessage();
60         notificationMsg.setDigest(digestMessage);
61         notificationMsg.setHeader(header);
62
63         // Uncomment if you want a body message
64
/*
65                  notificationMsg.setBody(bodyMessage);
66          */

67
68         byte[] msg = notificationMsg.computeTriggerNotificationMessage();
69
70         return msg;
71     }
72
73
74 }
Popular Tags