threema.d.ts 23 KB

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