Files
jami-daemon/tools/jamictrl/swarm.py
Maxim Cournoyer ba3a411ca3 daemon: Rename dring occurrences in code and file names to jamid.
Automated using the following commands:

  $ mv src/{dring,jami}
  $ git grep -l src/dring | xargs sed -i 's,src/dring,src/jami,g'
  $ git grep -l '#include "dring/' | \
    xargs sed -i 's,#include "dring/,#include "jami/,g'
  $ git grep -l 'dring.h' | xargs sed -i 's,dring.h,jami.h,g'

And finally,

  $ git grep -l 'dring' | xargs sed -i 's,dring,jami,g'

  $ files=$(find -name '*dring*' | sort)
  $ for f in $files; do mkdir -p "$(dirname "$f")"; \
      mv "$f" "$(echo $f | sed 's/dring/jami/g')"; done

To resolve a bad renaming favorably:

  $ git grep -l -i AlsaCarjami | \
    xargs sed -i -E 's/([Aa])lsaCarjami/\1lsaCardRingtone/g'

The above renaming command is not perfect, so some hand-tuning was
required to complete it.

* src/manager.cpp (Manager::ManagerPimpl::retrieveConfigPath):
Preserve the dring.yml configuration file name, until we add something
to migrate (rename) it to jami.yml.
* man/dring.pod: Delete.
* bin/dbus/jamid.pod: Move to ...
* man/jamid.pod: here.
* bin/dbus/meson.build (jamid_targets): Normalize man section to the
pre-existing 1 and adjust accordingly.
* src/jami/def.h (dring_EXPORTS): Rename to ...
(jami_EXPORTS): ... this.

change-Id: I9828be6da9c711ab2f22c4d1b9539fea89d7b6fb
2021-07-15 10:57:26 -04:00

99 lines
3.5 KiB
Python

#!/usr/bin/env python
#
# Copyright (C) 2020 Savoir-faire Linux Inc.
#
# Author: Sébastien Blin <sebastien.blin@savoirfairelinux.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from controller import DRingCtrl
import argparse
import sys
import signal
import os.path
import threading
parser = argparse.ArgumentParser()
parser.add_argument('--account', help='Account to use', metavar='<account>', type=str)
args = parser.parse_args()
ctrl = DRingCtrl(sys.argv[0], False)
if not args.account:
for account in ctrl.getAllEnabledAccounts():
details = ctrl.getAccountDetails(account)
if details['Account.type'] == 'RING':
args.account = account
break
if not args.account:
raise ValueError("no valid account")
def run_controller():
ctrl.run()
if __name__ == "__main__":
ctrlThread = threading.Thread(target=run_controller, args=(), daemon=True)
ctrlThread.start()
while True:
print("""Swarm options:
0. Create conversation
1. List conversations
2. List conversations members
3. Add Member
4. List requests
5. Accept request
6. Decline request
7. Load messages
8. Send message
9. Remove conversation
""")
opt = int(input("> "))
if opt == 0:
ctrl.startConversation(args.account)
elif opt == 1:
print(f'Conversations for account {args.account}:')
for conversation in ctrl.listConversations(args.account):
print(f'\t{conversation}')
elif opt == 2:
conversationId = input('Conversation: ')
print(f'Members for conversation {conversationId}:')
for member in ctrl.listConversationsMembers(args.account, conversationId):
print(f'{member["uri"]}')
elif opt == 3:
conversationId = input('Conversation: ')
contactUri = input('New member: ')
ctrl.addConversationMember(args.account, conversationId, contactUri)
elif opt == 4:
print(f'Conversations request for account {args.account}:')
for request in ctrl.listConversationsRequests(args.account):
print(f'{request["id"]}')
elif opt == 5:
conversationId = input('Conversation: ')
ctrl.acceptConversationRequest(args.account, conversationId)
elif opt == 6:
conversationId = input('Conversation: ')
ctrl.declineConversationRequest(args.account, conversationId)
elif opt == 8:
conversationId = input('Conversation: ')
message = input('Message: ')
ctrl.sendMessage(args.account, conversationId, message)
elif opt == 9:
conversationId = input('Conversation: ')
ctrl.removeConversation(args.account, conversationId)
else:
print('Not implemented yet')
ctrlThread.join()