const.py 25.1 KB
Newer Older
Philipp Hörist's avatar
Philipp Hörist committed
1
from enum import IntEnum, Enum, unique
Philipp Hörist's avatar
Philipp Hörist committed
2 3
from collections import namedtuple

4 5
from gi.repository import Gio

6 7
import nbxmpp

8
from gajim.common.i18n import _
9
from gajim.common.i18n import Q_
10

11 12
EncryptionData = namedtuple('EncryptionData', 'additional_data')
EncryptionData.__new__.__defaults__ = (None,)  # type: ignore
13 14


Philipp Hörist's avatar
Philipp Hörist committed
15
class AvatarSize(IntEnum):
16
    TAB = 16
Philipp Hörist's avatar
Philipp Hörist committed
17
    ROSTER = 32
Philipp Hörist's avatar
Philipp Hörist committed
18
    CHAT = 48
Philipp Hörist's avatar
Philipp Hörist committed
19 20 21
    NOTIFICATION = 48
    TOOLTIP = 125
    VCARD = 200
Philipp Hörist's avatar
Philipp Hörist committed
22
    PUBLISH = 200
Philipp Hörist's avatar
Philipp Hörist committed
23

24

25 26 27 28
class ArchiveState(IntEnum):
    NEVER = 0
    ALL = 1

29

30 31 32 33 34 35
@unique
class PathLocation(IntEnum):
    CONFIG = 0
    CACHE = 1
    DATA = 2

36

37 38 39 40
@unique
class PathType(IntEnum):
    FILE = 0
    FOLDER = 1
41
    FOLDER_OPTIONAL = 2
42

43

44 45 46 47 48 49 50 51 52 53 54 55 56 57
@unique
class KindConstant(IntEnum):
    STATUS = 0
    GCSTATUS = 1
    GC_MSG = 2
    SINGLE_MSG_RECV = 3
    CHAT_MSG_RECV = 4
    SINGLE_MSG_SENT = 5
    CHAT_MSG_SENT = 6
    ERROR = 7

    def __str__(self):
        return str(self.value)

58

59 60 61 62 63 64 65 66 67
@unique
class ShowConstant(IntEnum):
    ONLINE = 0
    CHAT = 1
    AWAY = 2
    XA = 3
    DND = 4
    OFFLINE = 5

68

69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
@unique
class TypeConstant(IntEnum):
    AIM = 0
    GG = 1
    HTTP_WS = 2
    ICQ = 3
    MSN = 4
    QQ = 5
    SMS = 6
    SMTP = 7
    TLEN = 8
    YAHOO = 9
    NEWMAIL = 10
    RSS = 11
    WEATHER = 12
    MRIM = 13
    NO_TRANSPORT = 14

87

88 89 90 91 92 93 94
@unique
class SubscriptionConstant(IntEnum):
    NONE = 0
    TO = 1
    FROM = 2
    BOTH = 3

95

96 97 98 99 100
@unique
class JIDConstant(IntEnum):
    NORMAL_TYPE = 0
    ROOM_TYPE = 1

Philipp Hörist's avatar
Philipp Hörist committed
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
@unique
class StyleAttr(Enum):
    COLOR = 'color'
    BACKGROUND = 'background'
    FONT = 'font'

@unique
class CSSPriority(IntEnum):
    APPLICATION = 600
    APPLICATION_DARK = 601
    DEFAULT_THEME = 610
    DEFAULT_THEME_DARK = 611
    USER_THEME = 650

@unique
class ButtonAction(Enum):
    DESTRUCTIVE = 'destructive-action'
    SUGGESTED = 'suggested-action'
119

Philipp Hörist's avatar
Philipp Hörist committed
120 121 122 123 124 125
@unique
class IdleState(IntEnum):
    UNKNOWN = 0
    XA = 1
    AWAY = 2
    AWAKE = 3
Philipp Hörist's avatar
Philipp Hörist committed
126

127

128 129 130 131 132 133
@unique
class RequestAvatar(IntEnum):
    SELF = 0
    ROOM = 1
    USER = 2

134

135 136
@unique
class PEPEventType(IntEnum):
137 138 139 140 141 142 143 144
    ABSTRACT = 0
    ACTIVITY = 1
    TUNE = 2
    MOOD = 3
    LOCATION = 4
    NICKNAME = 5
    AVATAR = 6
    ATOM = 7
145
    BOOKMARKS = 8
146 147


148 149 150 151 152 153 154 155 156 157 158 159
@unique
class Chatstate(IntEnum):
    COMPOSING = 0
    PAUSED = 1
    ACTIVE = 2
    INACTIVE = 3
    GONE = 4

    def __str__(self):
        return self.name.lower()


160 161 162 163 164 165 166
class SyncThreshold(IntEnum):
    NO_THRESHOLD = 0

    def __str__(self):
        return str(self.value)


167 168 169 170 171 172 173 174 175
class MUCUser(IntEnum):
    JID = 0
    NICK = 1
    REASON = 1
    NICK_OR_REASON = 1
    ROLE = 2
    AFFILIATION = 3
    AFFILIATION_TEXT = 4

176

177 178 179 180 181 182
@unique
class Trust(IntEnum):
    UNTRUSTED = 0
    UNDECIDED = 1
    BLIND = 2
    VERIFIED = 3
183

184 185 186 187 188 189 190 191

class Display(Enum):
    X11 = 'X11Display'
    WAYLAND = 'GdkWaylandDisplay'
    WIN32 = 'GdkWin32Display'
    QUARTZ = 'GdkQuartzDisplay'


192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
class URIType(Enum):
    UNKNOWN = 'unknown'
    XMPP = 'xmpp'
    MAIL = 'mail'
    GEO = 'geo'
    WEB = 'web'
    FILE = 'file'
    AT = 'at'


class URIAction(Enum):
    MESSAGE = 'message'
    JOIN = 'join'
    SUBSCRIBE = 'subscribe'


Philipp Hörist's avatar
Philipp Hörist committed
208 209 210 211
class MUCJoinedState(Enum):
    JOINED = 'joined'
    NOT_JOINED = 'not joined'
    JOINING = 'joining'
Philipp Hörist's avatar
Philipp Hörist committed
212
    CREATING = 'creating'
213 214
    CAPTCHA_REQUEST = 'captcha in progress'
    CAPTCHA_FAILED = 'captcha failed'
Philipp Hörist's avatar
Philipp Hörist committed
215 216 217 218 219

    def __str__(self):
        return self.name


220
class ClientState(IntEnum):
Philipp Hörist's avatar
Philipp Hörist committed
221 222 223 224 225
    DISCONNECTING = 0
    DISCONNECTED = 1
    RECONNECT_SCHEDULED = 2
    CONNECTING = 3
    CONNECTED = 4
226
    AVAILABLE = 5
Philipp Hörist's avatar
Philipp Hörist committed
227 228 229 230

    @property
    def is_disconnecting(self):
        return self == ClientState.DISCONNECTING
231 232 233 234 235

    @property
    def is_disconnected(self):
        return self == ClientState.DISCONNECTED

Philipp Hörist's avatar
Philipp Hörist committed
236 237 238 239
    @property
    def is_reconnect_scheduled(self):
        return self == ClientState.RECONNECT_SCHEDULED

240 241 242 243 244 245 246 247
    @property
    def is_connecting(self):
        return self == ClientState.CONNECTING

    @property
    def is_connected(self):
        return self == ClientState.CONNECTED

248 249 250 251
    @property
    def is_available(self):
        return self == ClientState.AVAILABLE

252

253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271
MUC_CREATION_EXAMPLES = [
    (Q_('?Group chat name:Team'),
     Q_('?Group chat description:Project discussion'),
     Q_('?Group chat address:team')),
    (Q_('?Group chat name:Family'),
     Q_('?Group chat description:Spring gathering'),
     Q_('?Group chat address:family')),
    (Q_('?Group chat name:Vacation'),
     Q_('?Group chat description:Trip planning'),
     Q_('?Group chat address:vacation')),
    (Q_('?Group chat name:Repairs'),
     Q_('?Group chat description:Local help group'),
     Q_('?Group chat address:repairs')),
    (Q_('?Group chat name:News'),
     Q_('?Group chat description:Local news and reports'),
     Q_('?Group chat address:news')),
]


272 273 274 275 276 277 278 279
MUC_DISCO_ERRORS = {
    'remote-server-not-found': _('Remote server not found'),
    'remote-server-timeout': _('Remote server timeout'),
    'service-unavailable': _('Address does not belong to a group chat server'),
    'subscription-required': _('Address does not belong to a group chat server'),
    'not-muc-service': _('Address does not belong to a group chat server'),
    'already-exists': _('Group chat already exists'),
    'item-not-found': _('Group chat does not exist'),
280
    'gone': _('Group chat is closed'),
281 282 283
}


Philipp Hörist's avatar
Philipp Hörist committed
284 285 286 287 288 289 290 291 292 293
EME_MESSAGES = {
    'urn:xmpp:otr:0':
        _('This message was encrypted with OTR '
          'and could not be decrypted.'),
    'jabber:x:encrypted':
        _('This message was encrypted with Legacy '
          'OpenPGP and could not be decrypted. You can install '
          'the PGP plugin to handle those messages.'),
    'urn:xmpp:openpgp:0':
        _('This message was encrypted with '
294 295
          'OpenPGP for XMPP and could not be decrypted. You can install '
          'the OpenPGP plugin to handle those messages.'),
Philipp Hörist's avatar
Philipp Hörist committed
296 297 298 299 300 301
    'fallback':
        _('This message was encrypted with %s '
          'and could not be decrypted.')
}


302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392
ACTIVITIES = {
    'doing_chores': {
        'category': _('Doing Chores'),
        'buying_groceries': _('Buying Groceries'),
        'cleaning': _('Cleaning'),
        'cooking': _('Cooking'),
        'doing_maintenance': _('Doing Maintenance'),
        'doing_the_dishes': _('Doing the Dishes'),
        'doing_the_laundry': _('Doing the Laundry'),
        'gardening': _('Gardening'),
        'running_an_errand': _('Running an Errand'),
        'walking_the_dog': _('Walking the Dog')},
    'drinking': {
        'category': _('Drinking'),
        'having_a_beer': _('Having a Beer'),
        'having_coffee': _('Having Coffee'),
        'having_tea': _('Having Tea')},
    'eating': {
        'category': _('Eating'),
        'having_a_snack': _('Having a Snack'),
        'having_breakfast': _('Having Breakfast'),
        'having_dinner': _('Having Dinner'),
        'having_lunch': _('Having Lunch')},
    'exercising': {
        'category': _('Exercising'),
        'cycling': _('Cycling'),
        'dancing': _('Dancing'),
        'hiking': _('Hiking'),
        'jogging': _('Jogging'),
        'playing_sports': _('Playing Sports'),
        'running': _('Running'),
        'skiing': _('Skiing'),
        'swimming': _('Swimming'),
        'working_out': _('Working out')},
    'grooming': {
        'category': _('Grooming'),
        'at_the_spa': _('At the Spa'),
        'brushing_teeth': _('Brushing Teeth'),
        'getting_a_haircut': _('Getting a Haircut'),
        'shaving': _('Shaving'),
        'taking_a_bath': _('Taking a Bath'),
        'taking_a_shower': _('Taking a Shower')},
    'having_appointment': {
        'category': _('Having an Appointment')},
    'inactive': {
        'category': _('Inactive'),
        'day_off': _('Day Off'),
        'hanging_out': _('Hanging out'),
        'hiding': _('Hiding'),
        'on_vacation': _('On Vacation'),
        'praying': _('Praying'),
        'scheduled_holiday': _('Scheduled Holiday'),
        'sleeping': _('Sleeping'),
        'thinking': _('Thinking')},
    'relaxing': {
        'category': _('Relaxing'),
        'fishing': _('Fishing'),
        'gaming': _('Gaming'),
        'going_out': _('Going out'),
        'partying': _('Partying'),
        'reading': _('Reading'),
        'rehearsing': _('Rehearsing'),
        'shopping': _('Shopping'),
        'smoking': _('Smoking'),
        'socializing': _('Socializing'),
        'sunbathing': _('Sunbathing'),
        'watching_tv': _('Watching TV'),
        'watching_a_movie': _('Watching a Movie')},
    'talking': {
        'category': _('Talking'),
        'in_real_life': _('In Real Life'),
        'on_the_phone': _('On the Phone'),
        'on_video_phone': _('On Video Phone')},
    'traveling': {
        'category': _('Traveling'),
        'commuting': _('Commuting'),
        'cycling': _('Cycling'),
        'driving': _('Driving'),
        'in_a_car': _('In a Car'),
        'on_a_bus': _('On a Bus'),
        'on_a_plane': _('On a Plane'),
        'on_a_train': _('On a Train'),
        'on_a_trip': _('On a Trip'),
        'walking': _('Walking')},
    'working': {
        'category': _('Working'),
        'coding': _('Coding'),
        'in_a_meeting': _('In a Meeting'),
        'studying': _('Studying'),
        'writing': _('Writing')}}

393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479
MOODS = {
    'afraid': _('Afraid'),
    'amazed': _('Amazed'),
    'amorous': _('Amorous'),
    'angry': _('Angry'),
    'annoyed': _('Annoyed'),
    'anxious': _('Anxious'),
    'aroused': _('Aroused'),
    'ashamed': _('Ashamed'),
    'bored': _('Bored'),
    'brave': _('Brave'),
    'calm': _('Calm'),
    'cautious': _('Cautious'),
    'cold': _('Cold'),
    'confident': _('Confident'),
    'confused': _('Confused'),
    'contemplative': _('Contemplative'),
    'contented': _('Contented'),
    'cranky': _('Cranky'),
    'crazy': _('Crazy'),
    'creative': _('Creative'),
    'curious': _('Curious'),
    'dejected': _('Dejected'),
    'depressed': _('Depressed'),
    'disappointed': _('Disappointed'),
    'disgusted': _('Disgusted'),
    'dismayed': _('Dismayed'),
    'distracted': _('Distracted'),
    'embarrassed': _('Embarrassed'),
    'envious': _('Envious'),
    'excited': _('Excited'),
    'flirtatious': _('Flirtatious'),
    'frustrated': _('Frustrated'),
    'grateful': _('Grateful'),
    'grieving': _('Grieving'),
    'grumpy': _('Grumpy'),
    'guilty': _('Guilty'),
    'happy': _('Happy'),
    'hopeful': _('Hopeful'),
    'hot': _('Hot'),
    'humbled': _('Humbled'),
    'humiliated': _('Humiliated'),
    'hungry': _('Hungry'),
    'hurt': _('Hurt'),
    'impressed': _('Impressed'),
    'in_awe': _('In Awe'),
    'in_love': _('In Love'),
    'indignant': _('Indignant'),
    'interested': _('Interested'),
    'intoxicated': _('Intoxicated'),
    'invincible': _('Invincible'),
    'jealous': _('Jealous'),
    'lonely': _('Lonely'),
    'lost': _('Lost'),
    'lucky': _('Lucky'),
    'mean': _('Mean'),
    'moody': _('Moody'),
    'nervous': _('Nervous'),
    'neutral': _('Neutral'),
    'offended': _('Offended'),
    'outraged': _('Outraged'),
    'playful': _('Playful'),
    'proud': _('Proud'),
    'relaxed': _('Relaxed'),
    'relieved': _('Relieved'),
    'remorseful': _('Remorseful'),
    'restless': _('Restless'),
    'sad': _('Sad'),
    'sarcastic': _('Sarcastic'),
    'satisfied': _('Satisfied'),
    'serious': _('Serious'),
    'shocked': _('Shocked'),
    'shy': _('Shy'),
    'sick': _('Sick'),
    'sleepy': _('Sleepy'),
    'spontaneous': _('Spontaneous'),
    'stressed': _('Stressed'),
    'strong': _('Strong'),
    'surprised': _('Surprised'),
    'thankful': _('Thankful'),
    'thirsty': _('Thirsty'),
    'tired': _('Tired'),
    'undefined': _('Undefined'),
    'weak': _('Weak'),
    'worried': _('Worried')
}

480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504
LOCATION_DATA = {
    'accuracy': _('accuracy'),
    'alt': _('alt'),
    'area': _('area'),
    'bearing': _('bearing'),
    'building': _('building'),
    'country': _('country'),
    'countrycode': _('countrycode'),
    'datum': _('datum'),
    'description': _('description'),
    'error': _('error'),
    'floor': _('floor'),
    'lat': _('lat'),
    'locality': _('locality'),
    'lon': _('lon'),
    'postalcode': _('postalcode'),
    'region': _('region'),
    'room': _('room'),
    'speed': _('speed'),
    'street': _('street'),
    'text': _('text'),
    'timestamp': _('timestamp'),
    'uri': _('URI')
}

505

506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538
SSLError = {
    2: _("Unable to get issuer certificate"),
    3: _("Unable to get certificate CRL"),
    4: _("Unable to decrypt certificate's signature"),
    5: _("Unable to decrypt CRL's signature"),
    6: _("Unable to decode issuer public key"),
    7: _("Certificate signature failure"),
    8: _("CRL signature failure"),
    9: _("Certificate is not yet valid"),
    10: _("Certificate has expired"),
    11: _("CRL is not yet valid"),
    12: _("CRL has expired"),
    13: _("Format error in certificate's notBefore field"),
    14: _("Format error in certificate's notAfter field"),
    15: _("Format error in CRL's lastUpdate field"),
    16: _("Format error in CRL's nextUpdate field"),
    17: _("Out of memory"),
    18: _("Self signed certificate"),
    19: _("Self signed certificate in certificate chain"),
    20: _("Unable to get local issuer certificate"),
    21: _("Unable to verify the first certificate"),
    22: _("Certificate chain too long"),
    23: _("Certificate revoked"),
    24: _("Invalid CA certificate"),
    25: _("Path length constraint exceeded"),
    26: _("Unsupported certificate purpose"),
    27: _("Certificate not trusted"),
    28: _("Certificate rejected"),
    29: _("Subject issuer mismatch"),
    30: _("Authority and subject key identifier mismatch"),
    31: _("Authority and issuer serial number mismatch"),
    32: _("Key usage does not include certificate signing"),
    50: _("Application verification failure"),
539
}
540 541


Philipp Hörist's avatar
Philipp Hörist committed
542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618
THANKS = u"""\
Alexander Futász
Alexander V. Butenko
Alexey Nezhdanov
Alfredo Junix
Anaël Verrier
Anders Ström
Andrew Sayman
Anton Shmigirilov
Christian Bjälevik
Christophe Got
Christoph Neuroth
David Campey
Dennis Craven
Fabian Neumann
Filippos Papadopoulos
Francisco Alburquerque Parra (Membris Khan)
Frederic Lory
Fridtjof Bussefor
Geobert Quach
Guillaume Morin
Gustavo J. A. M. Carneiro
Ivo Anjo
Josef Vybíral
Juraj Michalek
Kjell Braden
Luis Peralta
Michael Scherer
Michele Campeotto
Mike Albon
Miguel Fonseca
Norman Rasmussen
Oscar Hellström
Peter Saint-Andre
Petr Menšík
Sergey Kuleshov
Stavros Giannouris
Stian B. Barmen
Thilo Molitor
Thomas Klein-Hitpaß
Urtzi Alfaro
Witold Kieraś
Yakov Bezrukov
Yavor Doganov
""".strip().split("\n")

ARTISTS = u"""\
Anders Ström
Christophe Got
Dennis Craven
Dmitry Korzhevin
Guillaume Morin
Gvorcek Spajreh
Josef Vybíral
Membris Khan
Rederick Asher
Jakub Szypulka
""".strip().split("\n")

DEVS_CURRENT = u"""\
Yann Leboulanger (asterix AT lagaule.org)
Philipp Hörist (philipp AT hoerist.com)
""".strip().split("\n")

DEVS_PAST = u"""\
Stefan Bethge (stefan AT lanpartei.de)
Alexander Cherniuk (ts33kr AT gmail.com)
Stephan Erb (steve-e AT h3c.de)
Vincent Hanquez (tab AT snarc.org)
Dimitur Kirov (dkirov AT gmail.com)
Nikos Kouremenos (kourem AT gmail.com)
Julien Pivotto (roidelapluie AT gmail.com)
Jonathan Schleifer (js-gajim AT webkeks.org)
Travis Shirk (travis AT pobox.com)
Brendan Taylor (whateley AT gmail.com)
Jean-Marie Traissard (jim AT lapin.org)
""".strip().split("\n")
619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854


RFC5646_LANGUAGE_TAGS = {
    'af': 'Afrikaans',
    'af-ZA': 'Afrikaans (South Africa)',
    'ar': 'Arabic',
    'ar-AE': 'Arabic (U.A.E.)',
    'ar-BH': 'Arabic (Bahrain)',
    'ar-DZ': 'Arabic (Algeria)',
    'ar-EG': 'Arabic (Egypt)',
    'ar-IQ': 'Arabic (Iraq)',
    'ar-JO': 'Arabic (Jordan)',
    'ar-KW': 'Arabic (Kuwait)',
    'ar-LB': 'Arabic (Lebanon)',
    'ar-LY': 'Arabic (Libya)',
    'ar-MA': 'Arabic (Morocco)',
    'ar-OM': 'Arabic (Oman)',
    'ar-QA': 'Arabic (Qatar)',
    'ar-SA': 'Arabic (Saudi Arabia)',
    'ar-SY': 'Arabic (Syria)',
    'ar-TN': 'Arabic (Tunisia)',
    'ar-YE': 'Arabic (Yemen)',
    'az': 'Azeri (Latin)',
    'az-AZ': 'Azeri (Latin) (Azerbaijan)',
    'az-Cyrl-AZ': 'Azeri (Cyrillic) (Azerbaijan)',
    'be': 'Belarusian',
    'be-BY': 'Belarusian (Belarus)',
    'bg': 'Bulgarian',
    'bg-BG': 'Bulgarian (Bulgaria)',
    'bs-BA': 'Bosnian (Bosnia and Herzegovina)',
    'ca': 'Catalan',
    'ca-ES': 'Catalan (Spain)',
    'cs': 'Czech',
    'cs-CZ': 'Czech (Czech Republic)',
    'cy': 'Welsh',
    'cy-GB': 'Welsh (United Kingdom)',
    'da': 'Danish',
    'da-DK': 'Danish (Denmark)',
    'de': 'German',
    'de-AT': 'German (Austria)',
    'de-CH': 'German (Switzerland)',
    'de-DE': 'German (Germany)',
    'de-LI': 'German (Liechtenstein)',
    'de-LU': 'German (Luxembourg)',
    'dv': 'Divehi',
    'dv-MV': 'Divehi (Maldives)',
    'el': 'Greek',
    'el-GR': 'Greek (Greece)',
    'en': 'English',
    'en-AU': 'English (Australia)',
    'en-BZ': 'English (Belize)',
    'en-CA': 'English (Canada)',
    'en-CB': 'English (Caribbean)',
    'en-GB': 'English (United Kingdom)',
    'en-IE': 'English (Ireland)',
    'en-JM': 'English (Jamaica)',
    'en-NZ': 'English (New Zealand)',
    'en-PH': 'English (Republic of the Philippines)',
    'en-TT': 'English (Trinidad and Tobago)',
    'en-US': 'English (United States)',
    'en-ZA': 'English (South Africa)',
    'en-ZW': 'English (Zimbabwe)',
    'eo': 'Esperanto',
    'es': 'Spanish',
    'es-AR': 'Spanish (Argentina)',
    'es-BO': 'Spanish (Bolivia)',
    'es-CL': 'Spanish (Chile)',
    'es-CO': 'Spanish (Colombia)',
    'es-CR': 'Spanish (Costa Rica)',
    'es-DO': 'Spanish (Dominican Republic)',
    'es-EC': 'Spanish (Ecuador)',
    'es-ES': 'Spanish (Spain)',
    'es-GT': 'Spanish (Guatemala)',
    'es-HN': 'Spanish (Honduras)',
    'es-MX': 'Spanish (Mexico)',
    'es-NI': 'Spanish (Nicaragua)',
    'es-PA': 'Spanish (Panama)',
    'es-PE': 'Spanish (Peru)',
    'es-PR': 'Spanish (Puerto Rico)',
    'es-PY': 'Spanish (Paraguay)',
    'es-SV': 'Spanish (El Salvador)',
    'es-UY': 'Spanish (Uruguay)',
    'es-VE': 'Spanish (Venezuela)',
    'et': 'Estonian',
    'et-EE': 'Estonian (Estonia)',
    'eu': 'Basque',
    'eu-ES': 'Basque (Spain)',
    'fa': 'Farsi',
    'fa-IR': 'Farsi (Iran)',
    'fi': 'Finnish',
    'fi-FI': 'Finnish (Finland)',
    'fo': 'Faroese',
    'fo-FO': 'Faroese (Faroe Islands)',
    'fr': 'French',
    'fr-BE': 'French (Belgium)',
    'fr-CA': 'French (Canada)',
    'fr-CH': 'French (Switzerland)',
    'fr-FR': 'French (France)',
    'fr-LU': 'French (Luxembourg)',
    'fr-MC': 'French (Principality of Monaco)',
    'gl': 'Galician',
    'gl-ES': 'Galician (Spain)',
    'gu': 'Gujarati',
    'gu-IN': 'Gujarati (India)',
    'he': 'Hebrew',
    'he-IL': 'Hebrew (Israel)',
    'hi': 'Hindi',
    'hi-IN': 'Hindi (India)',
    'hr': 'Croatian',
    'hr-BA': 'Croatian (Bosnia and Herzegovina)',
    'hr-HR': 'Croatian (Croatia)',
    'hu': 'Hungarian',
    'hu-HU': 'Hungarian (Hungary)',
    'hy': 'Armenian',
    'hy-AM': 'Armenian (Armenia)',
    'id': 'Indonesian',
    'id-ID': 'Indonesian (Indonesia)',
    'is': 'Icelandic',
    'is-IS': 'Icelandic (Iceland)',
    'it': 'Italian',
    'it-CH': 'Italian (Switzerland)',
    'it-IT': 'Italian (Italy)',
    'ja': 'Japanese',
    'ja-JP': 'Japanese (Japan)',
    'ka': 'Georgian',
    'ka-GE': 'Georgian (Georgia)',
    'kk': 'Kazakh',
    'kk-KZ': 'Kazakh (Kazakhstan)',
    'kn': 'Kannada',
    'kn-IN': 'Kannada (India)',
    'ko': 'Korean',
    'ko-KR': 'Korean (Korea)',
    'kok': 'Konkani',
    'kok-IN': 'Konkani (India)',
    'ky': 'Kyrgyz',
    'ky-KG': 'Kyrgyz (Kyrgyzstan)',
    'lt': 'Lithuanian',
    'lt-LT': 'Lithuanian (Lithuania)',
    'lv': 'Latvian',
    'lv-LV': 'Latvian (Latvia)',
    'mi': 'Maori',
    'mi-NZ': 'Maori (New Zealand)',
    'mk': 'FYRO Macedonian',
    'mk-MK': 'FYRO Macedonian (Former Yugoslav Republic of Macedonia)',
    'mn': 'Mongolian',
    'mn-MN': 'Mongolian (Mongolia)',
    'mr': 'Marathi',
    'mr-IN': 'Marathi (India)',
    'ms': 'Malay',
    'ms-BN': 'Malay (Brunei Darussalam)',
    'ms-MY': 'Malay (Malaysia)',
    'mt': 'Maltese',
    'mt-MT': 'Maltese (Malta)',
    'nb': 'Norwegian (Bokm?l)',
    'nb-NO': 'Norwegian (Bokm?l) (Norway)',
    'nl': 'Dutch',
    'nl-BE': 'Dutch (Belgium)',
    'nl-NL': 'Dutch (Netherlands)',
    'nn-NO': 'Norwegian (Nynorsk) (Norway)',
    'ns': 'Northern Sotho',
    'ns-ZA': 'Northern Sotho (South Africa)',
    'pa': 'Punjabi',
    'pa-IN': 'Punjabi (India)',
    'pl': 'Polish',
    'pl-PL': 'Polish (Poland)',
    'ps': 'Pashto',
    'ps-AR': 'Pashto (Afghanistan)',
    'pt': 'Portuguese',
    'pt-BR': 'Portuguese (Brazil)',
    'pt-PT': 'Portuguese (Portugal)',
    'qu': 'Quechua',
    'qu-BO': 'Quechua (Bolivia)',
    'qu-EC': 'Quechua (Ecuador)',
    'qu-PE': 'Quechua (Peru)',
    'ro': 'Romanian',
    'ro-RO': 'Romanian (Romania)',
    'ru': 'Russian',
    'ru-RU': 'Russian (Russia)',
    'sa': 'Sanskrit',
    'sa-IN': 'Sanskrit (India)',
    'se': 'Sami',
    'se-FI': 'Sami (Finland)',
    'se-NO': 'Sami (Norway)',
    'se-SE': 'Sami (Sweden)',
    'sk': 'Slovak',
    'sk-SK': 'Slovak (Slovakia)',
    'sl': 'Slovenian',
    'sl-SI': 'Slovenian (Slovenia)',
    'sq': 'Albanian',
    'sq-AL': 'Albanian (Albania)',
    'sr-BA': 'Serbian (Latin) (Bosnia and Herzegovina)',
    'sr-Cyrl-BA': 'Serbian (Cyrillic) (Bosnia and Herzegovina)',
    'sr-SP': 'Serbian (Latin) (Serbia and Montenegro)',
    'sr-Cyrl-SP': 'Serbian (Cyrillic) (Serbia and Montenegro)',
    'sv': 'Swedish',
    'sv-FI': 'Swedish (Finland)',
    'sv-SE': 'Swedish (Sweden)',
    'sw': 'Swahili',
    'sw-KE': 'Swahili (Kenya)',
    'syr': 'Syriac',
    'syr-SY': 'Syriac (Syria)',
    'ta': 'Tamil',
    'ta-IN': 'Tamil (India)',
    'te': 'Telugu',
    'te-IN': 'Telugu (India)',
    'th': 'Thai',
    'th-TH': 'Thai (Thailand)',
    'tl': 'Tagalog',
    'tl-PH': 'Tagalog (Philippines)',
    'tn': 'Tswana',
    'tn-ZA': 'Tswana (South Africa)',
    'tr': 'Turkish',
    'tr-TR': 'Turkish (Turkey)',
    'tt': 'Tatar',
    'tt-RU': 'Tatar (Russia)',
    'ts': 'Tsonga',
    'uk': 'Ukrainian',
    'uk-UA': 'Ukrainian (Ukraine)',
    'ur': 'Urdu',
    'ur-PK': 'Urdu (Islamic Republic of Pakistan)',
    'uz': 'Uzbek (Latin)',
    'uz-UZ': 'Uzbek (Latin) (Uzbekistan)',
    'uz-Cyrl-UZ': 'Uzbek (Cyrillic) (Uzbekistan)',
    'vi': 'Vietnamese',
    'vi-VN': 'Vietnamese (Viet Nam)',
    'xh': 'Xhosa',
    'xh-ZA': 'Xhosa (South Africa)',
    'zh': 'Chinese',
    'zh-CN': 'Chinese (S)',
    'zh-HK': 'Chinese (Hong Kong)',
    'zh-MO': 'Chinese (Macau)',
    'zh-SG': 'Chinese (Singapore)',
    'zh-TW': 'Chinese (T)',
    'zu': 'Zulu',
    'zu-ZA': 'Zulu (South Africa)'
}
855 856 857 858 859 860 861 862 863 864 865 866

# pylint: disable=line-too-long
GIO_TLS_ERRORS = {
    Gio.TlsCertificateFlags.UNKNOWN_CA: _('The signing certificate authority is not known'),
    Gio.TlsCertificateFlags.REVOKED: _('The certificate has been revoked'),
    Gio.TlsCertificateFlags.BAD_IDENTITY: _('The certificate does not match the expected identity of the site'),
    Gio.TlsCertificateFlags.INSECURE: _('The certificate’s algorithm is insecure'),
    Gio.TlsCertificateFlags.NOT_ACTIVATED: _('The certificate’s activation time is in the future'),
    Gio.TlsCertificateFlags.GENERIC_ERROR: _('Unknown validation error'),
    Gio.TlsCertificateFlags.EXPIRED: _('The certificate has expired'),
}
# pylint: enable=line-too-long
Philipp Hörist's avatar
Philipp Hörist committed
867 868 869 870


class FTState(Enum):
    PREPARING = 'prepare'
Philipp Hörist's avatar
Philipp Hörist committed
871 872
    ENCRYPTING = 'encrypting'
    DECRYPTING = 'decrypting'
Philipp Hörist's avatar
Philipp Hörist committed
873 874 875 876 877 878 879 880 881 882 883 884 885
    STARTED = 'started'
    IN_PROGRESS = 'progress'
    FINISHED = 'finished'
    ERROR = 'error'

    @property
    def is_preparing(self):
        return self == FTState.PREPARING

    @property
    def is_encrypting(self):
        return self == FTState.ENCRYPTING

Philipp Hörist's avatar
Philipp Hörist committed
886 887 888 889
    @property
    def is_decrypting(self):
        return self == FTState.DECRYPTING

Philipp Hörist's avatar
Philipp Hörist committed
890 891 892 893 894 895 896 897 898 899 900 901 902 903 904
    @property
    def is_started(self):
        return self == FTState.STARTED

    @property
    def is_in_progress(self):
        return self == FTState.IN_PROGRESS

    @property
    def is_finished(self):
        return self == FTState.FINISHED

    @property
    def is_error(self):
        return self == FTState.ERROR
905 906 907 908 909 910 911 912 913 914 915 916 917 918 919


SASL_ERRORS = {
    'aborted': _('Authentication aborted'),
    'account-disabled': _('Account disabled'),
    'credentials-expired': _('Credentials expired'),
    'encryption-required': _('Encryption required'),
    'incorrect-encoding': _('Authentication failed'),
    'invalid-authzid': _('Authentication failed'),
    'malformed-request': _('Authentication failed'),
    'invalid-mechanism': _('Authentication mechanism not supported'),
    'mechanism-too-weak': _('Authentication mechanism too weak'),
    'not-authorized': _('Authentication failed'),
    'temporary-auth-failure': _('Authentication currently not possible'),
}
920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956


COMMON_FEATURES = [
    nbxmpp.NS_BYTESTREAM,
    nbxmpp.NS_MUC,
    nbxmpp.NS_COMMANDS,
    nbxmpp.NS_DISCO_INFO,
    nbxmpp.NS_LAST,
    nbxmpp.NS_DATA,
    nbxmpp.NS_ENCRYPTED,
    nbxmpp.NS_PING,
    nbxmpp.NS_CHATSTATES,
    nbxmpp.NS_RECEIPTS,
    nbxmpp.NS_TIME_REVISED,
    nbxmpp.NS_VERSION,
    nbxmpp.NS_ROSTERX,
    nbxmpp.NS_SECLABEL,
    nbxmpp.NS_CONFERENCE,
    nbxmpp.NS_CORRECT,
    nbxmpp.NS_EME,
    nbxmpp.NS_XHTML_IM,
    nbxmpp.NS_HASHES_2,
    nbxmpp.NS_HASHES_MD5,
    nbxmpp.NS_HASHES_SHA1,
    nbxmpp.NS_HASHES_SHA256,
    nbxmpp.NS_HASHES_SHA512,
    nbxmpp.NS_HASHES_SHA3_256,
    nbxmpp.NS_HASHES_SHA3_512,
    nbxmpp.NS_HASHES_BLAKE2B_256,
    nbxmpp.NS_HASHES_BLAKE2B_512,
    nbxmpp.NS_JINGLE,
    nbxmpp.NS_JINGLE_FILE_TRANSFER_5,
    nbxmpp.NS_JINGLE_XTLS,
    nbxmpp.NS_JINGLE_BYTESTREAM,
    nbxmpp.NS_JINGLE_IBB,
    nbxmpp.NS_AVATAR_METADATA + '+notify',
]