threema.d.ts 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869
  1. /**
  2. * This file is part of Threema Web.
  3. *
  4. * Threema Web is free software: you can redistribute it and/or modify it
  5. * under the terms of the GNU Affero General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or (at
  7. * your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Affero General Public License
  15. * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. declare const angular: ng.IAngularStatic;
  18. declare namespace threema {
  19. interface Avatar {
  20. // Low resolution avatar URI
  21. low?: ArrayBuffer;
  22. // High resolution avatar URI
  23. high?: ArrayBuffer;
  24. }
  25. /**
  26. * Messages that are sent through the secure data channel as encrypted msgpack bytes.
  27. */
  28. interface WireMessage {
  29. type: string;
  30. subType: string;
  31. args?: any;
  32. data?: any;
  33. }
  34. type MessageType = 'text' | 'image' | 'video' | 'audio' | 'location' | 'contact' |
  35. 'status' | 'ballot' | 'file' | 'voipStatus' | 'unknown';
  36. type MessageState = 'delivered' | 'read' | 'send-failed' | 'sent' | 'user-ack' |
  37. 'user-dec' | 'pending' | 'timeout' | 'sending';
  38. const enum InitializationStep {
  39. ClientInfo = 'client info',
  40. Conversations = 'conversations',
  41. Receivers = 'receivers',
  42. Profile = 'profile',
  43. }
  44. interface InitializationStepRoutine {
  45. requiredSteps: InitializationStep[];
  46. callback: any;
  47. }
  48. interface Thumbnail {
  49. img?: string;
  50. preview: ArrayBuffer;
  51. width: number;
  52. height: number;
  53. }
  54. const enum EventType {
  55. Created = 'created',
  56. Sent = 'sent',
  57. Delivered = 'delivered',
  58. Read = 'read',
  59. Acked = 'acked',
  60. Modified = 'modified',
  61. }
  62. /**
  63. * A message event, e.g. when it was delivered, read or modified.
  64. */
  65. interface MessageEvent {
  66. // The event type
  67. type: EventType;
  68. // Unix timestamp in seconds
  69. date: number;
  70. }
  71. /**
  72. * A Threema chat message.
  73. */
  74. interface Message {
  75. type: MessageType;
  76. id: string;
  77. body: string;
  78. thumbnail?: Thumbnail;
  79. date?: number;
  80. events?: MessageEvent[];
  81. sortKey: number;
  82. partnerId: string;
  83. isOutbox: boolean;
  84. isStatus: boolean;
  85. caption?: string;
  86. statusType?: 'text' | 'firstUnreadMessage';
  87. unread?: boolean;
  88. state?: MessageState;
  89. quote?: Quote;
  90. file?: FileInfo;
  91. video?: VideoInfo;
  92. audio?: AudioInfo;
  93. voip?: VoipStatusInfo;
  94. location?: LocationInfo;
  95. // only for temporary Messages
  96. temporaryId?: string;
  97. errorMessage?: string;
  98. }
  99. interface FileInfo {
  100. description: string;
  101. name: string;
  102. size: number;
  103. type: string;
  104. inApp: boolean;
  105. }
  106. interface VideoInfo {
  107. duration: number;
  108. size?: number;
  109. }
  110. interface AudioInfo {
  111. duration: number;
  112. }
  113. const enum VoipStatus {
  114. Missed = 1,
  115. Finished = 2,
  116. Rejected = 3,
  117. Aborted = 4,
  118. }
  119. const enum VoipRejectReason {
  120. Unknown = 0,
  121. Busy = 1,
  122. Timeout = 2,
  123. Rejected = 3,
  124. }
  125. interface VoipStatusInfo {
  126. status: VoipStatus;
  127. duration?: number;
  128. reason?: VoipRejectReason;
  129. }
  130. interface LocationInfo {
  131. lat: number;
  132. lon: number;
  133. accuracy: number;
  134. description: string;
  135. address?: string;
  136. }
  137. interface BlobInfo {
  138. buffer: ArrayBuffer;
  139. mimetype: string;
  140. filename: string;
  141. }
  142. /**
  143. * All possible receiver types.
  144. */
  145. type ReceiverType = 'me' | 'contact' | 'group' | 'distributionList';
  146. /**
  147. * Access Object for receivers
  148. */
  149. interface ReceiverAccess {
  150. canDelete?: boolean;
  151. }
  152. interface ContactReceiverAccess extends ReceiverAccess {
  153. canChangeAvatar: boolean;
  154. canChangeFirstName: boolean;
  155. canChangeLastName: boolean;
  156. }
  157. interface GroupReceiverAccess extends ReceiverAccess {
  158. canChangeAvatar: boolean;
  159. canChangeName: boolean;
  160. canChangeMembers?: boolean;
  161. canLeave?: boolean;
  162. canSync?: boolean;
  163. }
  164. interface DistributionListReceiverAccess extends ReceiverAccess {
  165. canChangeMembers?: boolean;
  166. }
  167. const enum IdentityType {
  168. Regular = 0,
  169. Work,
  170. }
  171. /**
  172. * The base class for a receiver. Only type and id.
  173. */
  174. interface BaseReceiver {
  175. id: string;
  176. type: ReceiverType;
  177. }
  178. /**
  179. * A generic receiver.
  180. *
  181. * Note that the id is not unique for all receivers, only for all receivers
  182. * of a certain type. The primary key for a receiver is the tuple (type, id).
  183. */
  184. interface Receiver extends BaseReceiver {
  185. // The display name
  186. displayName: string;
  187. // The color used for the avatar
  188. color: string;
  189. // The avatar, may be set if already fetched
  190. avatar?: Avatar;
  191. // Permissions towards this receiver
  192. access: ReceiverAccess;
  193. // Whether the chat with this receiver is locked. Used for private chats.
  194. locked?: boolean;
  195. // Whether the chat with this receiver is visible. Used for private chats.
  196. visible?: boolean;
  197. }
  198. /**
  199. * A contact.
  200. */
  201. interface ContactReceiver extends Receiver {
  202. // Flag indicating whether this is the own profile or another contact
  203. type: 'contact' | 'me';
  204. // Public nickname, if set
  205. publicNickname?: string;
  206. // First name, if set
  207. firstName?: string;
  208. // Last name, if set
  209. lastName?: string;
  210. // Verification level integer (1-3)
  211. verificationLevel?: number;
  212. // Feature mask
  213. featureMask: number | null;
  214. // The identity state
  215. state: 'ACTIVE' | 'INACTIVE';
  216. // Contact hidden?
  217. hidden: boolean;
  218. // The Threema public key
  219. publicKey: ArrayBuffer;
  220. // System confact information
  221. systemContact?: SystemContact;
  222. // Permissions towards this contact
  223. access: ContactReceiverAccess;
  224. // Whether this is a contact from the same Threema Work package.
  225. // Only relevant for Threema Work users.
  226. isWork?: boolean;
  227. // Whether this contact is blocked
  228. isBlocked?: boolean;
  229. // The identity type.
  230. // 0 - Regular Threema user.
  231. // 1 - Threema Work user.
  232. identityType?: IdentityType;
  233. }
  234. /**
  235. * Own contact.
  236. */
  237. interface MeReceiver extends ContactReceiver {
  238. type: 'me';
  239. }
  240. /**
  241. * A group.
  242. */
  243. interface GroupReceiver extends Receiver {
  244. type: 'group';
  245. disabled: boolean;
  246. members: string[];
  247. administrator: string;
  248. access: GroupReceiverAccess;
  249. createdAt: number;
  250. }
  251. /**
  252. * A distribution list.
  253. */
  254. interface DistributionListReceiver extends Receiver {
  255. type: 'distributionList';
  256. members: string[];
  257. access: DistributionListReceiverAccess;
  258. }
  259. interface SystemContact {
  260. emails?: SystemContactEmail[];
  261. phoneNumbers?: SystemContactPhone[];
  262. }
  263. interface SystemContactEmail {
  264. label: string;
  265. address: string;
  266. }
  267. interface SystemContactPhone {
  268. label: string;
  269. number: string;
  270. }
  271. /**
  272. * A conversation.
  273. */
  274. interface Conversation {
  275. type: ReceiverType;
  276. id: string;
  277. position?: number;
  278. messageCount: number;
  279. unreadCount: number;
  280. latestMessage: Message | null;
  281. receiver?: Receiver;
  282. avatar?: ArrayBuffer;
  283. notifications?: NotificationSettings;
  284. isStarred?: boolean;
  285. }
  286. /**
  287. * A conversation with a position field, used for updating a conversation.
  288. */
  289. interface ConversationWithPosition extends Conversation {
  290. position: number;
  291. }
  292. interface NotificationSettings {
  293. sound: NotificationSound;
  294. dnd: NotificationDnd;
  295. }
  296. interface NotificationSound {
  297. mode: NotificationSoundMode;
  298. }
  299. const enum NotificationSoundMode {
  300. Default = 'default',
  301. Muted = 'muted',
  302. }
  303. interface NotificationDnd {
  304. mode: NotificationDndMode;
  305. mentionOnly?: boolean;
  306. until?: number;
  307. }
  308. const enum NotificationDndMode {
  309. Off = 'off',
  310. On = 'on',
  311. Until = 'until',
  312. }
  313. /**
  314. * A form of the notification settings where things like the "until" mode
  315. * have been processed already.
  316. */
  317. interface SimplifiedNotificationSettings {
  318. sound: {
  319. muted: boolean,
  320. };
  321. dnd: {
  322. enabled: boolean,
  323. mentionOnly: boolean,
  324. };
  325. }
  326. /**
  327. * Connection state in the welcome dialog.
  328. *
  329. * States:
  330. *
  331. * - new: Initial state
  332. * - connecting: Connecting to signaling server
  333. * - push: When trying to reconnect, waiting for push notification to arrive
  334. * - manual_start: When trying to reconnect, waiting for manual session start
  335. * - already_connected: When the user is already connected in another tab or window
  336. * - waiting: Waiting for new-responder message from signaling server
  337. * - peer_handshake: Doing SaltyRTC handshake with the peer
  338. * - loading: Loading initial data
  339. * - done: Initial loading is finished
  340. * - closed: Connection is closed
  341. *
  342. */
  343. type ConnectionBuildupState = 'new' | 'connecting' | 'push' | 'manual_start' | 'already_connected'
  344. | 'waiting' | 'peer_handshake' | 'loading' | 'done' | 'closed';
  345. interface ConnectionBuildupStateChange {
  346. state: ConnectionBuildupState;
  347. prevState: ConnectionBuildupState;
  348. }
  349. /**
  350. * Connection state of the task peer connection.
  351. */
  352. const enum TaskConnectionState {
  353. New = 'new',
  354. Connecting = 'connecting',
  355. Connected = 'connected',
  356. Reconnecting = 'reconnecting',
  357. Disconnected = 'disconnected',
  358. }
  359. /**
  360. * Connection state of the WebRTC peer connection.
  361. */
  362. const enum GlobalConnectionState {
  363. Ok = 'ok',
  364. Warning = 'warning',
  365. Error = 'error',
  366. }
  367. interface GlobalConnectionStateChange {
  368. state: GlobalConnectionState;
  369. prevState: GlobalConnectionState;
  370. }
  371. /**
  372. * Type of message to be sent to a receiver.
  373. */
  374. type MessageContentType = 'text' | 'file';
  375. interface MessageData {
  376. // optional quote object
  377. quote?: Quote;
  378. }
  379. /**
  380. * Payload for a file message.
  381. */
  382. interface FileMessageData extends MessageData {
  383. // File name
  384. name: string;
  385. // File MIME type
  386. fileType: string;
  387. // Size in bytes
  388. size: number;
  389. // File bytes
  390. data: ArrayBuffer;
  391. // Caption string
  392. caption?: string;
  393. // Send as file message
  394. sendAsFile?: boolean;
  395. }
  396. /**
  397. * Payload for a text message.
  398. */
  399. interface TextMessageData extends MessageData {
  400. // Text to be sent
  401. text: string;
  402. }
  403. /**
  404. * The $stateParams format used for the welcome controller.
  405. */
  406. interface WelcomeStateParams extends ng.ui.IStateParamsService {
  407. initParams: null | {keyStore: saltyrtc.KeyStore, peerTrustedKey: Uint8Array};
  408. }
  409. interface CreateReceiverStateParams extends ng.ui.IStateParamsService {
  410. type: ReceiverType;
  411. initParams: null | {identity: string | null};
  412. }
  413. interface ConversationStateParams extends ng.ui.IStateParamsService {
  414. type: ReceiverType;
  415. id: string;
  416. initParams: null | {text: string | null};
  417. }
  418. interface Quote {
  419. identity: string;
  420. text: string;
  421. }
  422. const enum PushTokenType {
  423. Gcm = 'gcm',
  424. Apns = 'apns',
  425. }
  426. const enum PushTokenPrefix {
  427. Gcm = 'g',
  428. Apns = 'a',
  429. }
  430. const enum WakeupType {
  431. // A full reconnect (by entering the password on the main screen).
  432. FullReconnect = '0',
  433. // A wakeup, as implemented by the iOS app.
  434. Wakeup = '1',
  435. }
  436. interface TrustedKeyStoreData {
  437. ownPublicKey: Uint8Array;
  438. ownSecretKey: Uint8Array;
  439. peerPublicKey: Uint8Array;
  440. pushToken: string | null;
  441. pushTokenType: PushTokenType | null;
  442. }
  443. const enum BrowserName {
  444. Chrome = 'chrome',
  445. Firefox = 'firefox',
  446. InternetExplorer = 'ie',
  447. Edge = 'edge',
  448. Opera = 'opera',
  449. Safari = 'safari',
  450. }
  451. interface BrowserInfo {
  452. chrome: boolean;
  453. firefox: boolean;
  454. ie: boolean;
  455. edge: boolean;
  456. opera: boolean;
  457. safari: boolean;
  458. name?: BrowserName;
  459. version?: number;
  460. textInfo?: string;
  461. }
  462. interface PromiseCallbacks {
  463. resolve: (arg: any) => void;
  464. reject: (arg: any) => void;
  465. }
  466. interface PromiseRequestResult<T> {
  467. success: boolean;
  468. error?: string;
  469. data?: T;
  470. }
  471. type OnRemovedCallback = (identity: string) => void;
  472. const enum ControllerModelMode {
  473. NEW = 'new',
  474. VIEW = 'view',
  475. EDIT = 'edit',
  476. CHAT = 'chat',
  477. }
  478. const enum ContactReceiverFeature {
  479. AUDIO = 0x01,
  480. GROUP_CHAT = 0x02,
  481. BALLOT = 0x04,
  482. FILE = 0x08,
  483. VOIP = 0x10,
  484. }
  485. interface ControllerModel<T extends BaseReceiver> {
  486. /**
  487. * The title shown in the header.
  488. */
  489. subject: string;
  490. /**
  491. * Loading state.
  492. */
  493. isLoading: boolean;
  494. /**
  495. * Save the changes, return a promise with the receiver.
  496. */
  497. save(): Promise<T>;
  498. /**
  499. * Delete all messages in this conversation.
  500. */
  501. clean(ev: any): any;
  502. /**
  503. * Validate this receiver.
  504. */
  505. isValid(): boolean;
  506. /*
  507. * Return whether this receiver can be chatted with.
  508. */
  509. canChat(): boolean;
  510. /**
  511. * Can this receiver be edited?
  512. */
  513. canEdit(): boolean;
  514. /**
  515. * Can this receiver be cleaned?
  516. */
  517. canClean(): boolean;
  518. /*
  519. * Return whether this receiver can show a QR code of the public key.
  520. */
  521. canShowQr(): boolean;
  522. /**
  523. * The editing mode, e.g. view or edit this receiver.
  524. */
  525. getMode(): ControllerModelMode;
  526. /**
  527. * Set the on removed callback.
  528. */
  529. setOnRemoved(callback: OnRemovedCallback): void;
  530. /**
  531. * Callback called when the members change.
  532. */
  533. onChangeMembers(identities: string[]): void;
  534. /**
  535. * Return the members of this receiver.
  536. */
  537. getMembers(): string[];
  538. }
  539. interface Alert {
  540. source: string;
  541. type: string;
  542. message: string;
  543. }
  544. interface ReceiverListener {
  545. onConversationRemoved(receiver: Receiver);
  546. }
  547. interface Config {
  548. SELF_HOSTED: boolean;
  549. PREV_PROTOCOL_LAST_VERSION: string | null;
  550. GIT_BRANCH: string;
  551. SALTYRTC_PORT: number;
  552. SALTYRTC_SERVER_KEY: string | null;
  553. SALTYRTC_HOST: string | null;
  554. SALTYRTC_HOST_PREFIX: string | null;
  555. SALTYRTC_HOST_SUFFIX: string | null;
  556. ICE_SERVERS: RTCIceServer[];
  557. PUSH_URL: string;
  558. DEBUG: boolean;
  559. MSG_DEBUGGING: boolean;
  560. MSGPACK_DEBUGGING: boolean;
  561. ICE_DEBUGGING: boolean;
  562. }
  563. interface InitialConversationData {
  564. draft: string;
  565. initialText: string;
  566. }
  567. interface BrowserMinVersions {
  568. FF: number;
  569. CHROME: number;
  570. OPERA: number;
  571. SAFARI: number;
  572. }
  573. interface BatteryStatus {
  574. percent: number | null;
  575. isCharging: boolean;
  576. }
  577. const enum OperatingSystem {
  578. Android = 'android',
  579. Ios = 'ios',
  580. }
  581. interface ClientInfo {
  582. device: string;
  583. os: OperatingSystem;
  584. osVersion: string;
  585. isWork: boolean;
  586. pushToken?: string;
  587. configuration: AppConfig;
  588. capabilities: AppCapabilities;
  589. }
  590. interface AppConfig {
  591. voipEnabled: boolean;
  592. voipForceTurn: boolean;
  593. largeSingleEmoji: boolean;
  594. showInactiveIDs: boolean;
  595. }
  596. interface AppCapabilities {
  597. maxGroupSize: number;
  598. maxFileSize: number;
  599. distributionLists: boolean;
  600. imageFormat: ImageFormat;
  601. mdm?: MdmRestrictions;
  602. }
  603. /**
  604. * MIME types for the images exchanged between app and browser.
  605. */
  606. interface ImageFormat {
  607. avatar: string;
  608. thumbnail: string;
  609. }
  610. interface MdmRestrictions {
  611. disableAddContact?: boolean;
  612. disableCreateGroup?: boolean;
  613. disableSaveToGallery?: boolean;
  614. disableExport?: boolean;
  615. disableMessagePreview?: boolean;
  616. disableCalls?: boolean;
  617. readonlyProfile?: boolean;
  618. }
  619. interface ProfileUpdate {
  620. publicNickname?: string;
  621. avatar?: ArrayBuffer;
  622. }
  623. interface Profile extends ProfileUpdate {
  624. identity: string;
  625. publicKey: ArrayBuffer;
  626. }
  627. interface Mention {
  628. identity: string;
  629. query: string;
  630. isAll: boolean;
  631. }
  632. interface WordResult {
  633. // The trimmed word
  634. word: string;
  635. // The length of the untrimmed word
  636. realLength: number;
  637. }
  638. const enum ChosenTask {
  639. None = 'none',
  640. WebRTC = 'webrtc',
  641. RelayedData = 'relayed-data',
  642. }
  643. interface DisconnectMessage {
  644. type: 'disconnect';
  645. forget: boolean;
  646. reason: DisconnectReason;
  647. }
  648. const enum DisconnectReason {
  649. SessionStopped = 1,
  650. SessionDeleted = 2,
  651. WebclientDisabled = 3,
  652. SessionReplaced = 4,
  653. }
  654. namespace Container {
  655. interface ReceiverData {
  656. contacts: ContactReceiver[];
  657. groups: GroupReceiver[];
  658. distributionLists: DistributionListReceiver[];
  659. }
  660. interface Converter {
  661. unicodeToEmoji(message);
  662. addReceiverToConversation(receivers: Receivers);
  663. }
  664. interface Filters {
  665. hasData(receivers);
  666. hasContact(contacts);
  667. isValidMessage(contacts);
  668. }
  669. interface Receivers {
  670. me: MeReceiver;
  671. contacts: Map<string, ContactReceiver>;
  672. groups: Map<string, GroupReceiver>;
  673. distributionLists: Map<string, DistributionListReceiver>;
  674. get(receiverType: ReceiverType): Receiver | Map<string, Receiver>;
  675. getData(receiver: BaseReceiver): Receiver | null;
  676. set(data: ReceiverData): void;
  677. setMe(data: MeReceiver): void;
  678. setContacts(data: ContactReceiver[]): void;
  679. setGroups(data: GroupReceiver[]): void;
  680. setDistributionLists(data: DistributionListReceiver[]): void;
  681. extend(receiverType: ReceiverType, data: Receiver): Receiver;
  682. extendDistributionList(data: DistributionListReceiver): DistributionListReceiver;
  683. extendGroup(data: GroupReceiver): GroupReceiver;
  684. extendMe(data: MeReceiver): MeReceiver;
  685. extendContact(data: ContactReceiver): ContactReceiver;
  686. }
  687. interface Conversations {
  688. get(): Conversation[];
  689. set(data: Conversation[]): void;
  690. find(pattern: Conversation | Receiver): Conversation | null;
  691. add(conversation: Conversation): void;
  692. updateOrAdd(conversation: Conversation): Conversation | null;
  693. remove(conversation: Conversation): void;
  694. setFilter(filter: (data: Conversation[]) => Conversation[]): void;
  695. setConverter(converter: (data: Conversation) => Conversation): void;
  696. }
  697. interface Messages {
  698. converter: (data: Message) => Message;
  699. getList(receiver: BaseReceiver): Message[];
  700. clear($scope: ng.IScope): void;
  701. clearReceiverMessages(receiver: BaseReceiver): number;
  702. contains(receiver: BaseReceiver): boolean;
  703. hasMore(receiver: BaseReceiver): boolean;
  704. setMore(receiver: BaseReceiver, more: boolean): void;
  705. getReferenceMsgId(receiver: BaseReceiver): string;
  706. isRequested(receiver: BaseReceiver): boolean;
  707. setRequested(receiver: BaseReceiver): void;
  708. clearRequested(receiver: BaseReceiver): void;
  709. addNewer(receiver: BaseReceiver, messages: Message[]): void;
  710. addOlder(receiver: BaseReceiver, messages: Message[]): void;
  711. update(receiver: BaseReceiver, message: Message): boolean;
  712. setThumbnail(receiver: BaseReceiver, messageId: string, thumbnailImage: string): boolean;
  713. remove(receiver: BaseReceiver, messageId: string): boolean;
  714. removeTemporary(receiver: BaseReceiver, temporaryMessageId: string): boolean;
  715. bindTemporaryToMessageId(receiver: BaseReceiver, temporaryId: string, messageId: string): boolean;
  716. notify(receiver: BaseReceiver, $scope: ng.IScope): void;
  717. register(receiver: BaseReceiver, $scope: ng.IScope, callback: any): Message[];
  718. updateFirstUnreadMessage(receiver: BaseReceiver);
  719. }
  720. interface Typing {
  721. setTyping(receiver: ContactReceiver): void;
  722. unsetTyping(receiver: ContactReceiver): void;
  723. clearAll(): void;
  724. isTyping(receiver: ContactReceiver): boolean;
  725. }
  726. interface Drafts {
  727. setQuote(receiver: Receiver, quote: Quote): void;
  728. removeQuote(receiver: Receiver): void;
  729. getQuote(receiver: Receiver): Quote;
  730. setText(receiver: Receiver, draftMessage: string): void;
  731. removeText(receiver: Receiver): void;
  732. getText(receiver: Receiver): string;
  733. }
  734. interface Factory {
  735. Converter: Container.Converter;
  736. Filters: Container.Filters;
  737. createReceivers: () => Receivers;
  738. createConversations: () => Conversations;
  739. createMessages: () => Messages;
  740. createTyping: () => Typing;
  741. createDrafts: () => Drafts;
  742. }
  743. }
  744. }