add an option to allow disabling sending local time. Fixes #6764
This commit is contained in:
		
							parent
							
								
									caf9d69bfc
								
							
						
					
					
						commit
						23d3d79f83
					
				
					 2 changed files with 27 additions and 14 deletions
				
			
		| 
						 | 
					@ -366,7 +366,8 @@ class Config:
 | 
				
			||||||
                    'subscribe_nick': [opt_bool, True],
 | 
					                    'subscribe_nick': [opt_bool, True],
 | 
				
			||||||
                    'subscribe_location': [opt_bool, True],
 | 
					                    'subscribe_location': [opt_bool, True],
 | 
				
			||||||
                    'ignore_unknown_contacts': [ opt_bool, False ],
 | 
					                    'ignore_unknown_contacts': [ opt_bool, False ],
 | 
				
			||||||
                    'send_os_info': [ opt_bool, True ],
 | 
					                    'send_os_info': [ opt_bool, True, _("Allow Gajim to send information about the operating system you are running.") ],
 | 
				
			||||||
 | 
					                    'send_time_info': [ opt_bool, True, _("Allow Gajim to send your local time.") ],
 | 
				
			||||||
                    'log_encrypted_sessions': [opt_bool, True, _('When negotiating an encrypted session, should Gajim assume you want your messages to be logged?')],
 | 
					                    'log_encrypted_sessions': [opt_bool, True, _('When negotiating an encrypted session, should Gajim assume you want your messages to be logged?')],
 | 
				
			||||||
                    'send_idle_time': [ opt_bool, True ],
 | 
					                    'send_idle_time': [ opt_bool, True ],
 | 
				
			||||||
                    'roster_version': [opt_str, ''],
 | 
					                    'roster_version': [opt_str, ''],
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1496,12 +1496,18 @@ ConnectionJingle, ConnectionIBBytestream):
 | 
				
			||||||
    def _nec_time_request_received(self, obj):
 | 
					    def _nec_time_request_received(self, obj):
 | 
				
			||||||
        if obj.conn.name != self.name:
 | 
					        if obj.conn.name != self.name:
 | 
				
			||||||
            return
 | 
					            return
 | 
				
			||||||
 | 
					        if gajim.config.get_per('accounts', self.name, 'send_time_info'):
 | 
				
			||||||
            iq_obj = obj.stanza.buildReply('result')
 | 
					            iq_obj = obj.stanza.buildReply('result')
 | 
				
			||||||
            qp = iq_obj.getTag('query')
 | 
					            qp = iq_obj.getTag('query')
 | 
				
			||||||
            qp.setTagData('utc', strftime('%Y%m%dT%H:%M:%S', gmtime()))
 | 
					            qp.setTagData('utc', strftime('%Y%m%dT%H:%M:%S', gmtime()))
 | 
				
			||||||
            qp.setTagData('tz', helpers.decode_string(tzname[daylight]))
 | 
					            qp.setTagData('tz', helpers.decode_string(tzname[daylight]))
 | 
				
			||||||
            qp.setTagData('display', helpers.decode_string(strftime('%c',
 | 
					            qp.setTagData('display', helpers.decode_string(strftime('%c',
 | 
				
			||||||
                localtime())))
 | 
					                localtime())))
 | 
				
			||||||
 | 
					        else:
 | 
				
			||||||
 | 
					            iq_obj = obj.stanza.buildReply('error')
 | 
				
			||||||
 | 
					            err = common.xmpp.ErrorNode(name=common.xmpp.NS_STANZAS + \
 | 
				
			||||||
 | 
					                ' service-unavailable')
 | 
				
			||||||
 | 
					            iq_obj.addChild(node=err)
 | 
				
			||||||
        self.connection.send(iq_obj)
 | 
					        self.connection.send(iq_obj)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def _TimeRevisedCB(self, con, iq_obj):
 | 
					    def _TimeRevisedCB(self, con, iq_obj):
 | 
				
			||||||
| 
						 | 
					@ -1515,6 +1521,7 @@ ConnectionJingle, ConnectionIBBytestream):
 | 
				
			||||||
    def _nec_time_revised_request_received(self, obj):
 | 
					    def _nec_time_revised_request_received(self, obj):
 | 
				
			||||||
        if obj.conn.name != self.name:
 | 
					        if obj.conn.name != self.name:
 | 
				
			||||||
            return
 | 
					            return
 | 
				
			||||||
 | 
					        if gajim.config.get_per('accounts', self.name, 'send_time_info'):
 | 
				
			||||||
            iq_obj = obj.stanza.buildReply('result')
 | 
					            iq_obj = obj.stanza.buildReply('result')
 | 
				
			||||||
            qp = iq_obj.setTag('time', namespace=common.xmpp.NS_TIME_REVISED)
 | 
					            qp = iq_obj.setTag('time', namespace=common.xmpp.NS_TIME_REVISED)
 | 
				
			||||||
            qp.setTagData('utc', strftime('%Y-%m-%dT%H:%M:%SZ', gmtime()))
 | 
					            qp.setTagData('utc', strftime('%Y-%m-%dT%H:%M:%SZ', gmtime()))
 | 
				
			||||||
| 
						 | 
					@ -1522,6 +1529,11 @@ ConnectionJingle, ConnectionIBBytestream):
 | 
				
			||||||
            zone = -(timezone, altzone)[isdst] / 60.0
 | 
					            zone = -(timezone, altzone)[isdst] / 60.0
 | 
				
			||||||
            tzo = (zone / 60, abs(zone % 60))
 | 
					            tzo = (zone / 60, abs(zone % 60))
 | 
				
			||||||
            qp.setTagData('tzo', '%+03d:%02d' % (tzo))
 | 
					            qp.setTagData('tzo', '%+03d:%02d' % (tzo))
 | 
				
			||||||
 | 
					        else:
 | 
				
			||||||
 | 
					            iq_obj = obj.stanza.buildReply('error')
 | 
				
			||||||
 | 
					            err = common.xmpp.ErrorNode(name=common.xmpp.NS_STANZAS + \
 | 
				
			||||||
 | 
					                ' service-unavailable')
 | 
				
			||||||
 | 
					            iq_obj.addChild(node=err)
 | 
				
			||||||
        self.connection.send(iq_obj)
 | 
					        self.connection.send(iq_obj)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def _TimeRevisedResultCB(self, con, iq_obj):
 | 
					    def _TimeRevisedResultCB(self, con, iq_obj):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue