/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set sw=2 ts=8 et ft=cpp : */
/* 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 protocol PContent;
include protocol PSmsRequest;
include SmsTypes;

namespace mozilla {
namespace dom {
namespace sms {

struct SmsFilterData {
  uint64_t      startDate;
  uint64_t      endDate;
  nsString[]    numbers;
  DeliveryState delivery;
  ReadState     read;  
};

struct SendMessageRequest
{
  nsString number;
  nsString message;
};

struct GetMessageRequest
{
  int32_t messageId;
};

struct DeleteMessageRequest
{
  int32_t messageId;
};

struct CreateMessageListRequest
{
  SmsFilterData filter;
  bool reverse;
};

struct GetNextMessageInListRequest
{
  int32_t aListId;
};

struct MarkMessageReadRequest
{
  int32_t messageId;
  bool value;
};

struct GetThreadListRequest
{
};

union IPCSmsRequest
{
  SendMessageRequest;
  GetMessageRequest;
  DeleteMessageRequest;
  CreateMessageListRequest;
  GetNextMessageInListRequest;
  MarkMessageReadRequest;
  GetThreadListRequest;
};

sync protocol PSms {
    manager PContent;
    manages PSmsRequest;

child:
  NotifyReceivedMessage(SmsMessageData aMessageData);

  NotifySentMessage(SmsMessageData aMessageData);

  NotifyDeliverySuccessMessage(SmsMessageData aMessageData);

  NotifyDeliveryErrorMessage(SmsMessageData aMessageData);

parent:
  /**
   * Sent when the child no longer needs to use sms.
   */
  __delete__();

  /**
   * Sent when the child makes an asynchronous request to the parent.
   */
  PSmsRequest(IPCSmsRequest request);

  sync HasSupport()
      returns (bool aHasSupport);

  sync GetNumberOfMessagesForText(nsString aText)
      returns (uint16_t aNumber);

  sync SaveReceivedMessage(nsString aSender, nsString aBody, nsString aMessageClass, uint64_t aDate)
      returns (int32_t aId);

  sync SaveSentMessage(nsString aReceiver, nsString aBody, uint64_t aDate)
      returns (int32_t aId);

  SetMessageDeliveryStatus(int32_t aMessageId, nsString aDeliveryStatus);

  ClearMessageList(int32_t aListId);
};

} // namespace sms
} // namespace dom
} // namespace mozilla
