'Handle a startup event.'

@flow.EventHandler(allow_client_access=True, auth_required=False)
def ProcessMessage(self, message=None, event=None):

    _ = event
    if (message.auth_state != rdf_flows.GrrMessage.AuthorizationState.AUTHENTICATED):
        return
    client_id = message.source
    client = aff4.FACTORY.Create(client_id, aff4_grr.VFSGRRClient, mode='rw', token=self.token)
    old_info = client.Get(client.Schema.CLIENT_INFO)
    old_boot = client.Get(client.Schema.LAST_BOOT_TIME, 0)
    startup_info = rdf_client.StartupInfo(message.payload)
    info = startup_info.client_info
    new_data = (info.client_name, info.client_version, info.revision, info.build_time, info.client_description)
    old_data = (old_info.client_name, old_info.client_version, old_info.revision, old_info.build_time, old_info.client_description)
    if (new_data != old_data):
        client.Set(client.Schema.CLIENT_INFO(info))
    client.AddLabels(owner='GRR', *info.labels)
    if (abs((int(old_boot) - int(startup_info.boot_time))) > (300 * 1000000.0)):
        client.Set(client.Schema.LAST_BOOT_TIME(startup_info.boot_time))
    client.Close()
    events.Events.PublishEventInline('ClientStartup', message, token=self.token)
