Exemple #1
0
    def __init__(self, channel, psService, gWindow, sticky=False):
        super(ChatRoomWidget, self).__init__(gWindow, sticky=sticky)

        self.lock = aiorwlock.RWLock()
        self.chans = ChatChannels()

        self.pSub = psSubscriber(f'chatroom.{channel}')
        self.pSub.add_async_listener(keyChatChanUserList,
                                     self.onChatChanUserList)
        self.pSub.add_async_listener(makeKeyPubChatTokens(channel),
                                     self.onChatTokenMessage)

        self.participantsModel = ParticipantsModel(self)
        self.participantsModel.setHorizontalHeaderLabels(
            ['Token', 'SpaceHandle'])

        self.chatView = ChatWebView(self)

        self.channel = channel
        self.subscriber = psSubscriber(psService.topic)
        self.psService = psService
        self.subscriber.add_async_listener(self.psService.psKey,
                                           self.onChatMessageReceived)
        self.chatWidget = QWidget()
        self.vLayout.addWidget(self.chatWidget)

        self.ui = ui_chatroom.Ui_Form()
        self.ui.setupUi(self.chatWidget)
        self.ui.hLayoutTop.addWidget(self.chatView)

        self.ui.hideUsersButton.clicked.connect(self.onHideUsers)

        self.ui.usersView.setModel(self.participantsModel)
        self.ui.usersView.hideColumn(0)
Exemple #2
0
    def __init__(self, channel, psService, gWindow):
        super(ChatRoomWidget, self).__init__(gWindow)

        self.lock = asyncio.Lock()

        self.participantsModel = ParticipantsModel(self)
        self.participantsModel.setHorizontalHeaderLabels(['SpaceHandle', 'HB'])

        self.channel = channel
        self.subscriber = psSubscriber(psService.topic)
        self.psService = psService
        self.subscriber.add_async_listener(self.psService.psKey,
                                           self.onChatMessageReceived)
        self.chatWidget = QWidget()
        self.vLayout.addWidget(self.chatWidget)

        self.ui = ui_chatroom.Ui_Form()
        self.ui.setupUi(self.chatWidget)
        self.ui.chatLog.setOpenExternalLinks(False)
        self.ui.chatLog.setOpenLinks(False)
        self.ui.chatLog.anchorClicked.connect(
            partialEnsure(self.onAnchorClicked))

        self.ui.sendButton.clicked.connect(self.onSendMessage)
        self.ui.message.returnPressed.connect(self.onSendMessage)
        self.ui.message.setFocusPolicy(Qt.StrongFocus)
        self.ui.chatLog.setFocusPolicy(Qt.NoFocus)

        self.ui.usersView.setModel(self.participantsModel)
        self.ui.usersView.hideColumn(0)
Exemple #3
0
    def __init__(self, ipfsCtx, **kw):
        super(PSChatService, self).__init__(
            ipfsCtx, topic=TOPIC_CHAT,
            runPeriodic=True,
            **kw)
        self.pSubscriber = psSubscriber('ps-chat')
        self.pSubscriber.add_async_listener(
            keyChatChanList, self.onUserChannelList)

        self.chanUsers = {}
        self.tokManager = PubChatTokensManager()

        self.tokManager.sChanChanged.connectTo(self.onChanChanged)
        self.tokManager.sTokenStatus.connectTo(self.onTokenStatus)
Exemple #4
0
    def __init__(self, gWindow):
        super(PubsubSnifferWidget, self).__init__(gWindow)

        self.subscriber = psSubscriber('pubsub_sniffer')

        self.tableWidget = QTableWidget(self)
        self.tableWidget.setHorizontalHeaderLabels(
            ['Date', 'Topic', 'Sender', ''])
        self.tableWidget.setColumnCount(4)
        self.tableWidget.verticalHeader().hide()
        self.tableWidget.horizontalHeader().hide()

        horizHeader = self.tableWidget.horizontalHeader()
        horizHeader.setSectionResizeMode(QHeaderView.ResizeToContents)
        self.vLayout.addWidget(self.tableWidget)

        self.subscriber.add_async_listener(keyPsJson, self.onJsonMessage)
        self.subscriber.add_async_listener(keyPsEncJson, self.onJsonMessage)
Exemple #5
0
    def __init__(self, ipfsCtx,
                 channel: str, topic: str,
                 jwsTokenCid, privEccKey, psKey, **kw):
        super(PSEncryptedChatChannelService, self).__init__(
            ipfsCtx,
            topic,
            privEccKey,
            runPeriodic=True,
            peered=False,
            minMsgTsDiff=1,
            filterSelfMessages=False, **kw)

        self.channel = channel
        self.psKey = psKey
        self.privEccKey = privEccKey
        self.jwsTokenCid = jwsTokenCid

        self.mChatService = ipfsCtx.pubsub.byTopic(TOPIC_CHAT)

        self.pSubscriber = psSubscriber(topic)
        self.pSubscriber.add_sync_listener(
            keyChatChanUserList, self.onChatChanUserList)
Exemple #6
0
from py3crdt.gset import GSet

from galacteek import log
from galacteek.core.ps import keyChatChannels
from galacteek.core.ps import psSubscriber
from galacteek.ipfs.dag import EvolvingDAG

subscriber = psSubscriber('chat_channels_messages')


class ChannelsDAG(EvolvingDAG):
    def __init__(self, *args, **kw):
        super().__init__(*args, **kw)

        self.gsetLocal = GSet(id='localchannels')
        self.available.connectTo(self.onAvailable)
        subscriber.add_async_listener(keyChatChannels, self.onChatChannels)

    async def initDag(self, ipfsop):
        return {'channels': {'all': ['#galacteek', '#ipfs'], 'favourites': []}}

    @property
    def channels(self):
        return self.root['channels']['all']

    @property
    def privateChannels(self):
        return self.root['channels']['private']

    @property
    def channelsSorted(self):
Exemple #7
0
from galacteek.did import normedUtcDate
from galacteek.did import didIdentRe
from galacteek.ipfs.tunnel import P2PListener
from galacteek.ipfs import ipfsOp
from galacteek.ipfs.p2pservices import P2PService
from galacteek.core import jsonSchemaValidate
from galacteek.core import utcDatetimeIso
from galacteek.core.ps import psSubscriber
from galacteek.core.ps import keyTokensIdent
from galacteek.crypto.rsa import RSAExecutor
from galacteek import log

from aiohttp import web


pSubscriber = psSubscriber('p2p_didauth')


authReqSchema = {
    "title": "DID Auth challenge request",
    "description": "DID Auth challenge",
    "type": "object",
    "properties": {
        "did": {
            "type": "string"
        },
        "nonce": {
            "type": "string"
        },
        "challenge": {
            "type": "string"
Exemple #8
0
from galacteek.core.asynclib import asyncify
from galacteek.core.asynclib import async_enterable
from galacteek.core.ipfsmarks import IPFSMarks

from galacteek.core.ps import keyPsJson
from galacteek.core.ps import keyPsEncJson
from galacteek.core.ps import psSubscriber
from galacteek.core.ps import gHub

from galacteek.database.psmanager import psManagerForTopic

from galacteek.services import GService

import aioipfs

psServSubscriber = psSubscriber('pubsubServices')

PS_ENCTYPE_NULL = 0
PS_ENCTYPE_JSON_RAW = 1
PS_ENCTYPE_RSA_AES = 2
PS_ENCTYPE_CURVE25519 = 3


class MsgSpy(object):
    def __init__(self, psDbManager, msgRecord, msgType, name, value):
        self.psDbManager = psDbManager
        self.msgType = msgType
        self.attrName = name
        self.value = value
        self.msgRecord = msgRecord
Exemple #9
0
from PyQt5.QtWidgets import QVBoxLayout
from PyQt5.QtWidgets import QHeaderView
from PyQt5.QtWidgets import QToolButton

from PyQt5.QtGui import QTextCursor
from PyQt5.QtCore import Qt

from galacteek.core import datetimeIsoH

from galacteek.core.ps import keyPsJson
from galacteek.core.ps import psSubscriber

from .helpers import getIcon
from .widgets import GalacteekTab

subscriber = psSubscriber('pubsub_sniffer')


class PubsubSnifferWidget(GalacteekTab):
    def __init__(self, gWindow):
        super(PubsubSnifferWidget, self).__init__(gWindow)

        self.tableWidget = QTableWidget(self)
        self.tableWidget.setHorizontalHeaderLabels(
            ['Date', 'Topic', 'Sender', ''])
        self.tableWidget.setColumnCount(4)
        self.tableWidget.verticalHeader().hide()
        self.tableWidget.horizontalHeader().hide()

        horizHeader = self.tableWidget.horizontalHeader()
        horizHeader.setSectionResizeMode(QHeaderView.ResizeToContents)
Exemple #10
0
from asyncio_throttle import Throttler

from galacteek.ipfs.tunnel import P2PListener
from galacteek.ipfs import ipfsOp
from galacteek.ipfs.p2pservices import P2PService
from galacteek.core import jsonSchemaValidate
from galacteek.core.asynclib import loopTime
from galacteek.core.ps import psSubscriber
from galacteek.core.ps import keyTokensDagExchange
from galacteek.core.ps import keySnakeDagExchange
from galacteek import log

from aiohttp import web

pSubscriber = psSubscriber('p2p_dagexchange')

dagCidSignSchema = {
    'title': 'DAG CID sign request',
    'type': 'object',
    'properties': {
        'elixir': {
            'type': 'string',
            'pattern': r'[a-f0-9]{64}'
        },
        'sessiontoken': {
            'type': 'string',
            'pattern': r'[a-f0-9]{64,128}'
        }
    },
    'required': ['elixir', 'sessiontoken']