"Fossies" - the Fresh Open Source Software Archive

Member "deltachat-desktop-1.3.4/src/renderer/delta-remote.ts" (18 May 2020, 8030 Bytes) of package /linux/misc/deltachat-desktop-1.3.4.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) TypeScript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "delta-remote.ts": 1.3.3_vs_1.3.4.

    1 import { DeltaChat, ChatList, C } from 'deltachat-node'
    2 import { _callDcMethodAsync } from './ipc'
    3 import {
    4   FullChat,
    5   ChatListItemType,
    6   MessageType,
    7   JsonLocations,
    8 } from '../shared/shared-types'
    9 import { LocaleData } from '../shared/localize'
   10 
   11 class DeltaRemote {
   12   // root ---------------------------------------------------------------
   13   call(fnName: 'updateBlockedContacts'): Promise<void>
   14   call(fnName: 'setProfilePicture', newImage: string): Promise<void>
   15   call(fnName: 'getProfilePicture'): Promise<string>
   16   call(fnName: 'getInfo'): Promise<any>
   17   call(
   18     fnName: 'getProviderInfo',
   19     email: string
   20   ): Promise<{
   21     before_login_hint: any
   22     overview_page: any
   23     status: any
   24   }>
   25   call(fnName: 'joinSecurejoin', qrCode: string): Promise<number>
   26   call(fnName: 'stopOngoingProcess'): Promise<number>
   27   call(
   28     fnName: 'checkQrCode',
   29     qrCode: string
   30   ): Promise<{
   31     state: number
   32     text1: string
   33     text1Meaning: string
   34     text2: string
   35     timestamp: number
   36     id: number
   37   }>
   38   // autocrypt ----------------------------------------------------------
   39   call(
   40     fnName: 'autocrypt.initiateKeyTransfer',
   41     ...args: Parameters<typeof DeltaChat.prototype.initiateKeyTransfer>
   42   ): Promise<void>
   43   call(
   44     fnName: 'autocrypt.continueKeyTransfer',
   45     ...args: Parameters<typeof DeltaChat.prototype.continueKeyTransfer>
   46   ): Promise<string>
   47   // backup -------------------------------------------------------------
   48   call(fnName: 'backup.export', dir: string): Promise<void>
   49   call(fnName: 'backup.import', file: string): Promise<void>
   50   // chatList -----------------------------------------------------------
   51   call(fnName: 'chatList.selectChat', chatId: number): Promise<FullChat>
   52   call(fnName: 'chatList.getSelectedChatId'): Promise<number>
   53   call(fnName: 'chatList.onChatModified', chatId: number): Promise<void>
   54   call(
   55     fnName: 'chatList.getChatListIds',
   56     listFlags: number,
   57     queryStr: string,
   58     queryContactId: number
   59   ): Promise<number[]>
   60   call(
   61     fnName: 'chatList.getChatListItemsByIds',
   62     chatIds: number[]
   63   ): Promise<{
   64     [key: number]: ChatListItemType
   65   }>
   66   call(fnName: 'chatList.getFullChatById', chatId: number): Promise<FullChat>
   67   call(fnName: 'chatList.getGeneralFreshMessageCounter'): Promise<number> // this method might be used for a favicon badge counter
   68   // contacts ------------------------------------------------------------
   69   call(fnName: 'contacts.unblockContact', contactId: number): Promise<void>
   70   call(fnName: 'contacts.blockContact', contactId: number): Promise<void>
   71   call(
   72     fnName: 'contacts.changeNickname',
   73     contactId: number,
   74     name: string
   75   ): Promise<number>
   76   call(
   77     fnName: 'contacts.acceptContactRequest',
   78     {
   79       messageId,
   80       contactId,
   81     }: {
   82       messageId: number
   83       contactId: number
   84     }
   85   ): Promise<number>
   86   call(
   87     fnName: 'contacts.createContact',
   88     email: string,
   89     name?: string
   90   ): Promise<number>
   91   call(
   92     fnName: 'contacts.createChatByContactId',
   93     contactId: number
   94   ): Promise<number>
   95   call(
   96     fnName: 'contacts.getContact',
   97     contactId: number
   98   ): Promise<{
   99     address: string
  100     color: number
  101     displayName: string
  102     firstName: string
  103     id: number
  104     name: string
  105     profileImage: string
  106     nameAndAddr: string
  107     isBlocked: boolean
  108     isVerified: boolean
  109   }>
  110   call(fnName: 'contacts.markNoticedContact', contactId: number): Promise<void>
  111   call(
  112     fnName: 'contacts.getChatIdByContactId',
  113     contactId: number
  114   ): Promise<number>
  115   call(fnName: 'contacts.getDMChatId', contactId: number): Promise<number>
  116   // chat ---------------------------------------------------------------
  117   call(
  118     fnName: 'chat.getChatMedia',
  119     msgType1: number,
  120     msgType2: number
  121   ): Promise<MessageType[]>
  122   call(fnName: 'chat.getEncryptionInfo', contactId: number): Promise<string>
  123   call(fnName: 'chat.getQrCode', chatId?: number): Promise<string>
  124   call(fnName: 'chat.leaveGroup', chatId: number): Promise<void>
  125   call(fnName: 'chat.setName', chatId: number, name: string): Promise<boolean>
  126   call(
  127     fnName: 'chat.modifyGroup',
  128     chatId: number,
  129     name: string,
  130     image: string,
  131     remove: number[],
  132     add: number[]
  133   ): Promise<boolean>
  134   call(
  135     fnName: 'chat.addContactToChat',
  136     chatId: number,
  137     contactId: number
  138   ): Promise<boolean>
  139   call(
  140     fnName: 'chat.setProfileImage',
  141     chatId: number,
  142     newImage: string
  143   ): Promise<boolean>
  144   call(
  145     fnName: 'chat.createGroupChat',
  146     verified: boolean,
  147     name: string
  148   ): Promise<number>
  149   call(fnName: 'chat.delete', chatId: number): Promise<void>
  150   call(
  151     fnName: 'chat.setVisibility',
  152     chatId: number,
  153     visibility:
  154       | C.DC_CERTCK_AUTO
  155       | C.DC_CERTCK_STRICT
  156       | C.DC_CHAT_VISIBILITY_PINNED
  157   ): Promise<void>
  158   call(fnName: 'chat.getChatContacts', chatId: number): Promise<number[]>
  159   call(fnName: 'chat.markNoticedChat', chatId: number): Promise<void>
  160   // locations ----------------------------------------------------------
  161   call(
  162     fnName: 'locations.setLocation',
  163     latitude: number,
  164     longitude: number,
  165     accuracy: number
  166   ): Promise<void>
  167   call(
  168     fnName: 'locations.getLocations',
  169     chatId: number,
  170     contactId: number,
  171     timestampFrom: number,
  172     timestampTo: number
  173   ): Promise<JsonLocations>
  174   // loginController ----------------------------------------------------
  175   // NOTHING HERE that is called directly from the frontend, yet
  176   // messageList --------------------------------------------------------
  177   call(
  178     fnName: 'messageList.sendMessage',
  179     chatId: number,
  180     text: string | null,
  181     filename?: string,
  182     location?: {
  183       lat: number
  184       lng: number
  185     }
  186   ): Promise<
  187     [
  188       number,
  189       (
  190         | MessageType
  191         | {
  192             msg: null
  193           }
  194       )
  195     ]
  196   >
  197   call(
  198     fnName: 'messageList.sendSticker',
  199     chatId: number,
  200     stickerPath: string
  201   ): Promise<void>
  202   call(fnName: 'messageList.deleteMessage', id: number): Promise<void>
  203   call(
  204     fnName: 'messageList.getMessage',
  205     msgId: number
  206   ): Promise<{ msg: null } | MessageType>
  207   call(
  208     fnName: 'messageList.getMessages',
  209     messageIds: number[]
  210   ): Promise<{ [key: number]: MessageType | { msg: null } }>
  211   call(fnName: 'messageList.getMessageInfo', msgId: number): Promise<string>
  212   call(
  213     fnName: 'messageList.setDraft',
  214     chatId: number,
  215     msgText: string
  216   ): Promise<void>
  217   call(
  218     fnName: 'messageList.messageIdToJson',
  219     id: number
  220   ): Promise<{ msg: null } | MessageType>
  221   call(fnName: 'messageList.getMessageIds', chatid: number): Promise<number[]>
  222   // settings -----------------------------------------------------------
  223   call(
  224     fnName: 'settings.setConfig',
  225     key: string,
  226     value: string
  227   ): Promise<number>
  228   call(fnName: 'settings.getConfig', key: string): Promise<string>
  229   call(
  230     fnName: 'settings.getConfigFor',
  231     keys: string[]
  232   ): Promise<{
  233     [key: string]: string
  234   }>
  235   call(fnName: 'settings.keysImport', directory: string): Promise<void>
  236   call(fnName: 'settings.keysExport', directory: string): Promise<void>
  237   call(
  238     fnName: 'settings.serverFlags',
  239     {
  240       mail_security,
  241       send_security,
  242     }: {
  243       mail_security?: string
  244       send_security?: string
  245     }
  246   ): Promise<number | ''>
  247   // stickers -----------------------------------------------------------
  248   call(
  249     fnName: 'stickers.getStickers'
  250   ): Promise<{
  251     [key: string]: string[]
  252   }>
  253   // context ------------------------------------------------------------
  254   call(fnName: 'context.maybeNetwork'): Promise<void>
  255   // extras -------------------------------------------------------------
  256   call(fnName: 'extras.getLocaleData', locale: string): Promise<LocaleData>
  257   // catchall: ----------------------------------------------------------
  258   call(fnName: string): Promise<any>
  259   call(fnName: string, ...args: any[]): Promise<any> {
  260     return _callDcMethodAsync(fnName, ...[...arguments].slice(1))
  261   }
  262 }
  263 
  264 export const DeltaBackend = new DeltaRemote()