[GH-ISSUE #1022] Parameterize the IMAP folder path #815

Open
opened 2026-02-26 01:31:58 +03:00 by kerem · 4 comments
Owner

Originally created by @kurahaupo on GitHub (Jun 1, 2020).
Original GitHub issue: https://github.com/jberkel/sms-backup-plus/issues/1022

(This follows on from implementing multi-SIM.)

Allow tokens to be included in the Gmail label/IMAP folder, such as:

  • %{device_name} this phone's name
  • %{slot} the SIM slot number in this phone.
  • %{slot_id} the IMEI of (the SIM slot in) this phone
  • %{sim_id} the SIM's serial number (ICCID or IMSI)
  • %{sim_phone} the SIM's phone number (MSISDN)
  • %{phone} the other party's phone number (MSISDN or E.123 format if possible)
  • %{name} name of the other party (from Google Contacts; same as used for the subject line now)
  • %{kind} (a token such as SMS, MMS, RCS)
Originally created by @kurahaupo on GitHub (Jun 1, 2020). Original GitHub issue: https://github.com/jberkel/sms-backup-plus/issues/1022 (This follows on from implementing multi-SIM.) Allow tokens to be included in the Gmail label/IMAP folder, such as: * `%{device_name}` this phone's name * `%{slot}` the SIM slot number in this phone. * `%{slot_id}` the IMEI of (the SIM slot in) this phone * `%{sim_id}` the SIM's serial number (ICCID or IMSI) * `%{sim_phone}` the SIM's phone number (MSISDN) * `%{phone}` the other party's phone number (MSISDN or E.123 format if possible) * `%{name}` name of the other party (from Google Contacts; same as used for the subject line now) * `%{kind}` (a token such as `SMS`, `MMS`, `RCS`)
Author
Owner

@kurahaupo commented on GitHub (Jun 1, 2020):

The %{slot} notation could be expanded to allow %{slot+char} where char is any printable unicode character, indicating the first slot. The default would be +1 giving 1/2/3.

Other possibilities include:

  • 0/1/2
  • A/B/C
  • //
  • //
  • //.
  • α/β/γ
<!-- gh-comment-id:636605947 --> @kurahaupo commented on GitHub (Jun 1, 2020): The `%{slot}` notation could be expanded to allow `%{slot+`_char_`}` where _char_ is any printable unicode character, indicating the first slot. The default would be `+1` giving `1`/`2`/`3`. Other possibilities include: * `0`/`1`/`2` * `A`/`B`/`C` * `₁`/`₂`/`₃` * `❶`/`❷`/`❸` * `Ⅰ`/`Ⅱ`/`Ⅲ`. * `α`/`β`/`γ`
Author
Owner

@kurahaupo commented on GitHub (Jun 1, 2020):

It may then also make sense to use these same tokens for configuring the RFC2822 headers in the saved messages, rather than having specialized code in each case.

To that end, it may also be useful to recognize

  • %{time}, %{senttime}, %{recvtime}, %{now}, etc, with optional modifiers:
    • %{time±timezone}, where ±timezone is either
      • a numeric offset (+hh, -hh, +hhmm or -hhmm), or
      • + and a known timezone label to convert from UTC to that timezone, or
      • - and a known timezone label to convert from that timezone to UTC;
        multiple offsets can be given, in particular to convert from one timezone, to UTC, to another timezone. Timezone label local refers to the current primary timezone of the device.
    • %{time~format} where format is usable by strftime or similar.
  • %{my_email} the email address associated with the IMAP or Gmail account;
  • %{my_name} the name associated with the Gmail account;
  • %{my_phone} as an alias for (or replacement of) %{sim_phone} (above);
<!-- gh-comment-id:636606023 --> @kurahaupo commented on GitHub (Jun 1, 2020): It may then also make sense to use these same tokens for configuring the RFC2822 headers in the saved messages, rather than having specialized code in each case. To that end, it may also be useful to recognize * `%{time}`, `%{senttime}`, `%{recvtime}`, `%{now}`, etc, with optional modifiers: * `%{time`_±timezone_`}`, where _±timezone_ is either * a numeric offset (`+hh`, `-hh`, `+hhmm` or `-hhmm`), or * `+` and a known timezone label to convert from UTC to that timezone, or * `-` and a known timezone label to convert from that timezone to UTC; multiple offsets can be given, in particular to convert from one timezone, to UTC, to another timezone. Timezone label `local` refers to the current primary timezone of the device. * `%{time~`_format_`}` where _format_ is usable by `strftime` or similar. * `%{my_email}` the email address associated with the IMAP or Gmail account; * `%{my_name}` the name associated with the Gmail account; * `%{my_phone}` as an alias for (or replacement of) `%{sim_phone}` (above);
Author
Owner

@kurahaupo commented on GitHub (Jun 1, 2020):

I have in mind a generic parsing mechanism that would work through a string and pick out each token of the form %{…}, then from that take the first "C" identifier (matching /\<[[:alpha:]_][[:alnum:]]*\>/) and look that up to determine the precise function. The result from that function would replace the token in the initial string.

Modifiers could be introduced by any sensible punctuation, such as

  • parameters and type-specific modifiers:
    • +char after a numeric value such as slot
    • +number or -number after a numeric or time value
    • ~format as per strftime or sprintf
  • generic modifiers, as :modifier-function
    • :uc convert to uppercase
    • :lc convert to lowercase
    • :tc convert to titlecase
    • :lookup{value1|value2|value3|}

Any number of generic modifiers may be given after any specific ones, as they apply to whatever result is returned by the lookup and previous modifiers.

NB: this implies that the matching of %{ to } must take nested brackets into account.

<!-- gh-comment-id:636614332 --> @kurahaupo commented on GitHub (Jun 1, 2020): I have in mind a generic parsing mechanism that would work through a string and pick out each token of the form `%{…}`, then from that take the first "C" identifier (matching /`\<[[:alpha:]_][[:alnum:]]*\>`/) and look that up to determine the precise function. The result from that function would replace the token in the initial string. Modifiers could be introduced by any sensible punctuation, such as * parameters and type-specific modifiers: * `+`_char_ after a numeric value such as `slot` * `+`_number_ or `-`_number_ after a numeric or time value * `~`_format_ as per `strftime` or `sprintf` * generic modifiers, as `:`_modifier-function_ * `:uc` convert to uppercase * `:lc` convert to lowercase * `:tc` convert to titlecase * `:lookup{`_value1_`|`_value2_`|`_value3_`|`…`}` Any number of generic modifiers may be given after any specific ones, as they apply to whatever result is returned by the lookup and previous modifiers. NB: this implies that the matching of `%{` to `}` must take nested brackets into account.
Author
Owner

@kurahaupo commented on GitHub (Jun 1, 2020):

If anyone has any preferences for the start and end symbols, please say so now...

<!-- gh-comment-id:636617383 --> @kurahaupo commented on GitHub (Jun 1, 2020): If anyone has any preferences for the start and end symbols, please say so now...
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/sms-backup-plus-jberkel#815
No description provided.